Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mhoeschle/baslerpypylontools
1 result
Show changes
Commits on Source (5)
......@@ -54,6 +54,15 @@ for camera_serial_toml in cam_data_update.get('camera_ids').values():
# read Gain, Trigger delay, exposure, fps and gamma from camera
cam_control.readcam(cam_swig, cam_serial)
# change gain with value from toml file:
cam_control.gaincam(cam_swig, cam_serial, cam_data_update)
# change exposure with value from toml file:
cam_control.exposurecam(cam_swig, cam_serial, cam_data_update)
# change delay of the trigger (exposure) with value from toml file in milliseconds (ms):
cam_control.triggerdelaycam(cam_swig, cam_serial, cam_data_update)
# close camera
cam_control.closecam(cam_swig, cam_serial)
......
......@@ -56,3 +56,66 @@ def readcam(cam_swig, cam_serial):
# readcam(cam_swig, cam_serial)
def gaincam(cam_swig, cam_serial, cam_data_update):
"""
changes the gain in (dB). Entering float numbers for. e.g: 5.0
"""
gainvalue = cam_data_update.get('camera_parameters')['gain']
# Input new gain value
# gainvalue = float(input("Please enter the new gain in (dB): "))
# Set new value to camera
cam_swig.Gain.SetValue(gainvalue)
# Read Gain value in Camera:
updated_gain = cam_swig.Gain.GetValue()
updated_gain = round(updated_gain, 2)
print(
f'Updated_Gain in (dB): {updated_gain} from camera: {cam_serial}')
# cam_control.gaincam(cam_swig, cam_serial, cam_data_update)
#
# Funktion for changing the exposure time in miliseconds (e.g. 1000 ms):
#
def exposurecam(cam_swig, cam_serial, cam_data_update):
"""
changes the exposure time in miliseconds (ms)
"""
# new value from toml file
exposure_value = cam_data_update.get('camera_parameters')['exposure']
# add
new_exposure = float(exposure_value)
cam_swig.ExposureTime.SetValue(new_exposure)
# Read new exosure value in Camera:
print(
f'Updated_Exposure: {cam_swig.ExposureTime.GetValue()} from camera: {cam_serial}')
# exposurecam(cam_swig, cam_serial, cam_data_update)
#
# Funktion for changing the delay of the trigger in miliseconds (e.g. 1000 ms):
#
def triggerdelaycam(cam_swig, cam_serial, cam_data_update):
"""
changes the trigger delay in miliseconds (ms)
"""
# new value from toml file
delay_value = cam_data_update.get('camera_parameters')['delay']
cam_swig.TriggerDelay.SetValue(float(delay_value))
print(
f'New trigger delay from camera {cam_swig.TriggerDelay.GetValue()} is: {cam_serial}')
# triggerdelaycam(cam_swig, cam_serial, cam_data_update)
......@@ -6,11 +6,11 @@ camera_id_2 = 22320672
camera_id_3 = 2234
[connected_cameras]
23093107 = "<pypylon.pylon.InstantCamera; proxy of <Swig Object of type 'Pylon::CInstantCamera *' at 0x000002A58FD89020> >"
22320672 = "<pypylon.pylon.InstantCamera; proxy of <Swig Object of type 'Pylon::CInstantCamera *' at 0x00000206BC5B4D20> >"
[camera_swig]
[camera_parameters]
delaycam = 1000
exposurecam = 1000
gaincam = 1.0
delay = 500
exposure = 500
gain = 3.0
# {05D8C294-F295-4dfb-9D01-096BD04049F4}
# GenApi persistence file (version 3.1.0)
# Device = Basler::UsbCameraParams -- Basler USB3Vision camera interface -- Device version = 1.0.0 -- Product GUID = 5a809e15-f447-480f-a21f-0fb7256b8400 -- Product version GUID = BD8DAF13-291A-4A6B-A82A-EAC119712405
# Device = Basler::UsbCameraParams -- Basler USB3Vision camera interface -- Device version = 1.0.0 -- Product GUID = 5a809e15-f447-480f-a21f-0fb7256b8400 -- Product version GUID = 81106593-7AA4-421B-AA3C-9AAB82C85481
TimerSelector Timer1
TimerTriggerSource ExposureStart
TimerSelector Timer1
......@@ -76,21 +76,16 @@ def access_toml_file(cam_serial_swig_adress):
# for parameter in data.items():
# print(f'Parameter_after_updating: {parameter}')
# change data to update befor uploading to the file
cam_data_update = data
#
# Write to modified config:
#
# move to the end
with open(config_filename, "w") as f:
toml.dump(data, f)
#
# open toml file to use updated camera input and SWIG:
#
with open(config_filename, "rb") as f:
cam_data_update = tomllib.load(f)
for new_parameter in cam_data_update.items():
print(f'Updated_Parameter: {new_parameter}') # for debug
return cam_data_update
# access_toml_file(cam_serial_swig_adress)
......@@ -101,3 +96,5 @@ def access_toml_file(cam_serial_swig_adress):
# test2 = list(cam_data_update.get('connected_cameras').keys())[0]
# print(f'Camera_ID_Updated: {test2}')
# split into two files one read and other write