microeye 2.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- microEye/__init__.py +47 -0
- microEye/_version.py +2 -0
- microEye/analysis/__init__.py +1 -0
- microEye/analysis/checklist_dialog.py +143 -0
- microEye/analysis/cmosMaps.py +228 -0
- microEye/analysis/filters/__init__.py +9 -0
- microEye/analysis/filters/base.py +21 -0
- microEye/analysis/filters/spatial.py +338 -0
- microEye/analysis/filters/temporal.py +76 -0
- microEye/analysis/fitting/__init__.py +0 -0
- microEye/analysis/fitting/fit.py +680 -0
- microEye/analysis/fitting/nena.py +375 -0
- microEye/analysis/fitting/phasor_fit.py +90 -0
- microEye/analysis/fitting/processing.py +317 -0
- microEye/analysis/fitting/psf/__init__.py +6 -0
- microEye/analysis/fitting/psf/extract.py +1129 -0
- microEye/analysis/fitting/psf/rubost_mean.py +150 -0
- microEye/analysis/fitting/psf/spline.py +167 -0
- microEye/analysis/fitting/psf/stats/__init__.py +12 -0
- microEye/analysis/fitting/psf/stats/core.py +295 -0
- microEye/analysis/fitting/psf/stats/curve_fit.py +708 -0
- microEye/analysis/fitting/psf/stats/io.py +104 -0
- microEye/analysis/fitting/psf/stats/slope_fit.py +171 -0
- microEye/analysis/fitting/psf/temp.py +147 -0
- microEye/analysis/fitting/psf/test.py +47 -0
- microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUfunctions.py +657 -0
- microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUmleFit_LM.py +1336 -0
- microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUsplineLib.py +270 -0
- microEye/analysis/fitting/pyfit3Dcspline/CPU/__init__.py +1 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUfunctions.py +609 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_EMCCD.py +1396 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_sCMOS.py +1426 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUsplineLib.py +231 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/__init__.py +2 -0
- microEye/analysis/fitting/pyfit3Dcspline/__init__.py +10 -0
- microEye/analysis/fitting/pyfit3Dcspline/constants.py +27 -0
- microEye/analysis/fitting/pyfit3Dcspline/mainfunctions.py +903 -0
- microEye/analysis/fitting/results.py +917 -0
- microEye/analysis/fitting/results_stats.py +251 -0
- microEye/analysis/fitting/tardis.py +209 -0
- microEye/analysis/multi_viewer.py +568 -0
- microEye/analysis/processing/__init__.py +1 -0
- microEye/analysis/processing/frc.py +120 -0
- microEye/analysis/rendering/__init__.py +3 -0
- microEye/analysis/rendering/base.py +452 -0
- microEye/analysis/rendering/cloud.py +215 -0
- microEye/analysis/rendering/core.py +47 -0
- microEye/analysis/rendering/volumetric.py +198 -0
- microEye/analysis/tools/__init__.py +0 -0
- microEye/analysis/tools/kymograms.py +1079 -0
- microEye/analysis/tools/roi_selectors.py +556 -0
- microEye/analysis/utils/__init__.py +3 -0
- microEye/analysis/utils/coordinates.py +18 -0
- microEye/analysis/utils/images.py +68 -0
- microEye/analysis/utils/windows.py +19 -0
- microEye/analysis/viewer/__init__.py +3 -0
- microEye/analysis/viewer/image_options_widget.py +615 -0
- microEye/analysis/viewer/images.py +1225 -0
- microEye/analysis/viewer/layers_widget.py +415 -0
- microEye/analysis/viewer/localizations.py +1304 -0
- microEye/analysis/viewer/psf.py +1003 -0
- microEye/analysis/viewer/volume.py +456 -0
- microEye/hardware/__init__.py +3 -0
- microEye/hardware/cams/__init__.py +29 -0
- microEye/hardware/cams/camera_calibration.py +99 -0
- microEye/hardware/cams/camera_list.py +528 -0
- microEye/hardware/cams/camera_options.py +694 -0
- microEye/hardware/cams/camera_panel.py +941 -0
- microEye/hardware/cams/dummy/__init__.py +1 -0
- microEye/hardware/cams/dummy/dummy_panel.py +759 -0
- microEye/hardware/cams/jobs.py +497 -0
- microEye/hardware/cams/line_profiler.py +99 -0
- microEye/hardware/cams/linescan/IR_Cam.py +474 -0
- microEye/hardware/cams/linescan/__init__.py +1 -0
- microEye/hardware/cams/micam.py +524 -0
- microEye/hardware/cams/pco/__init__.py +58 -0
- microEye/hardware/cams/pco/enums.py +382 -0
- microEye/hardware/cams/pco/pco_cam.py +761 -0
- microEye/hardware/cams/pco/pco_panel.py +477 -0
- microEye/hardware/cams/shortcuts.py +312 -0
- microEye/hardware/cams/thorlabs/__init__.py +1 -0
- microEye/hardware/cams/thorlabs/thorlabs.py +1508 -0
- microEye/hardware/cams/thorlabs/thorlabs_panel.py +850 -0
- microEye/hardware/cams/ueye/__init__.py +1 -0
- microEye/hardware/cams/ueye/ueye_camera.py +1023 -0
- microEye/hardware/cams/ueye/ueye_panel.py +861 -0
- microEye/hardware/cams/vimba/__init__.py +1 -0
- microEye/hardware/cams/vimba/vimba_cam.py +1000 -0
- microEye/hardware/cams/vimba/vimba_panel.py +813 -0
- microEye/hardware/device.py +60 -0
- microEye/hardware/lasers/__init__.py +13 -0
- microEye/hardware/lasers/io_matchbox.py +791 -0
- microEye/hardware/lasers/io_params.py +85 -0
- microEye/hardware/lasers/io_single_laser.py +742 -0
- microEye/hardware/lasers/laser_relay.py +594 -0
- microEye/hardware/mieye/__init__.py +1 -0
- microEye/hardware/mieye/acquisition_manager.py +467 -0
- microEye/hardware/mieye/devices_manager.py +533 -0
- microEye/hardware/mieye/miEye.py +659 -0
- microEye/hardware/misc/__init__.py +0 -0
- microEye/hardware/misc/acquisition_view.py +71 -0
- microEye/hardware/misc/reglo.py +761 -0
- microEye/hardware/misc/temp.py +188 -0
- microEye/hardware/port_config.py +59 -0
- microEye/hardware/protocols/__init__.py +2 -0
- microEye/hardware/protocols/actions.py +402 -0
- microEye/hardware/protocols/actions_items.py +703 -0
- microEye/hardware/protocols/designer.py +244 -0
- microEye/hardware/protocols/scene_manager.py +191 -0
- microEye/hardware/protocols/serialization.py +97 -0
- microEye/hardware/pycromanager/__init__.py +16 -0
- microEye/hardware/pycromanager/core.py +1433 -0
- microEye/hardware/pycromanager/devices.py +461 -0
- microEye/hardware/pycromanager/enums.py +107 -0
- microEye/hardware/pycromanager/headless.py +153 -0
- microEye/hardware/pycromanager/utils.py +34 -0
- microEye/hardware/pycromanager/widgets/__init__.py +5 -0
- microEye/hardware/pycromanager/widgets/bridges.py +407 -0
- microEye/hardware/pycromanager/widgets/headless_manager.py +258 -0
- microEye/hardware/pycromanager/widgets/headless_options.py +224 -0
- microEye/hardware/pycromanager/widgets/pycro_panel.py +455 -0
- microEye/hardware/stages/__init__.py +18 -0
- microEye/hardware/stages/elliptec/__init__.py +5 -0
- microEye/hardware/stages/elliptec/baseDevice.py +314 -0
- microEye/hardware/stages/elliptec/device.py +384 -0
- microEye/hardware/stages/elliptec/deviceID.py +212 -0
- microEye/hardware/stages/elliptec/devicePort.py +379 -0
- microEye/hardware/stages/elliptec/deviceStatus.py +65 -0
- microEye/hardware/stages/elliptec/devicesView.py +706 -0
- microEye/hardware/stages/elliptec/ellDevices.py +134 -0
- microEye/hardware/stages/elliptec/messageUpdater.py +34 -0
- microEye/hardware/stages/elliptec/motorInfo.py +153 -0
- microEye/hardware/stages/elliptec/stage.py +62 -0
- microEye/hardware/stages/elliptec/test.py +139 -0
- microEye/hardware/stages/kinesis/__init__.py +1 -0
- microEye/hardware/stages/kinesis/kdc101/__init__.py +1 -0
- microEye/hardware/stages/kinesis/kdc101/enums.py +1002 -0
- microEye/hardware/stages/kinesis/kdc101/factory.py +171 -0
- microEye/hardware/stages/kinesis/kdc101/kdc101.py +718 -0
- microEye/hardware/stages/kinesis/kinesis.py +776 -0
- microEye/hardware/stages/piezo_concept.py +607 -0
- microEye/hardware/stages/stabilizer.py +785 -0
- microEye/hardware/stages/stage.py +89 -0
- microEye/hardware/widgets/__init__.py +10 -0
- microEye/hardware/widgets/controller.py +246 -0
- microEye/hardware/widgets/devices.py +133 -0
- microEye/hardware/widgets/focusWidget.py +264 -0
- microEye/hardware/widgets/qlist_slider.py +113 -0
- microEye/hardware/widgets/scan_acquisition.py +424 -0
- microEye/icons/1024.png +0 -0
- microEye/icons/128.png +0 -0
- microEye/icons/16.png +0 -0
- microEye/icons/24.png +0 -0
- microEye/icons/256.png +0 -0
- microEye/icons/32.png +0 -0
- microEye/icons/48.png +0 -0
- microEye/icons/512.png +0 -0
- microEye/icons/64.png +0 -0
- microEye/icons/__init__.py +0 -0
- microEye/icons/close.svg +88 -0
- microEye/icons/mieye.png +0 -0
- microEye/icons/min.svg +83 -0
- microEye/icons/viewer.png +0 -0
- microEye/launcher.py +42 -0
- microEye/qt.py +181 -0
- microEye/utils/__init__.py +2 -0
- microEye/utils/enum_encoder.py +10 -0
- microEye/utils/expandable_groupbox.py +93 -0
- microEye/utils/gui_helper.py +457 -0
- microEye/utils/hid/__init__.py +8 -0
- microEye/utils/hid/controller.py +153 -0
- microEye/utils/hid/device.py +63 -0
- microEye/utils/hid/enums.py +140 -0
- microEye/utils/hid/utils.py +58 -0
- microEye/utils/labelled_slider.py +134 -0
- microEye/utils/metadata.py +599 -0
- microEye/utils/metadata_tree.py +718 -0
- microEye/utils/micro_launcher.py +245 -0
- microEye/utils/parameter_tree.py +325 -0
- microEye/utils/pyscripting.py +444 -0
- microEye/utils/retry_exec.py +35 -0
- microEye/utils/start_gui.py +112 -0
- microEye/utils/thread_worker.py +115 -0
- microEye/utils/uImage.py +1512 -0
- microeye-2.3.2.dist-info/METADATA +401 -0
- microeye-2.3.2.dist-info/RECORD +190 -0
- microeye-2.3.2.dist-info/WHEEL +5 -0
- microeye-2.3.2.dist-info/entry_points.txt +2 -0
- microeye-2.3.2.dist-info/licenses/LICENSE +674 -0
- microeye-2.3.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1000 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
from tabulate import tabulate
|
|
6
|
+
|
|
7
|
+
from microEye.hardware.cams.micam import miCamera
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import vimba as vb
|
|
11
|
+
|
|
12
|
+
def get_camera_list():
|
|
13
|
+
cam_list = []
|
|
14
|
+
with vb.Vimba.get_instance() as vimba:
|
|
15
|
+
cams = vimba.get_all_cameras()
|
|
16
|
+
for cam in cams:
|
|
17
|
+
cam_list.append(
|
|
18
|
+
{
|
|
19
|
+
'Camera ID': cam.get_id(),
|
|
20
|
+
'Device ID': cam.get_interface_id(),
|
|
21
|
+
'Sensor ID': 'NA',
|
|
22
|
+
'Status': 'NA',
|
|
23
|
+
'InUse': 0,
|
|
24
|
+
'Model': cam.get_model(),
|
|
25
|
+
'Serial': cam.get_serial(),
|
|
26
|
+
'Driver': 'Vimba',
|
|
27
|
+
'Name': cam.get_name(),
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
return cam_list
|
|
31
|
+
|
|
32
|
+
def get_camera(camera_id: Optional[str]) -> vb.Camera: # type: ignore
|
|
33
|
+
with vb.Vimba.get_instance() as vimba:
|
|
34
|
+
if camera_id:
|
|
35
|
+
try:
|
|
36
|
+
return vimba.get_camera_by_id(camera_id)
|
|
37
|
+
except vb.VimbaCameraError:
|
|
38
|
+
print(f"Failed to access Camera '{camera_id}'. Abort.")
|
|
39
|
+
else:
|
|
40
|
+
cams = vimba.get_all_cameras()
|
|
41
|
+
if not cams:
|
|
42
|
+
print('No Cameras accessible. Abort.')
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
return cams[0]
|
|
46
|
+
except Exception:
|
|
47
|
+
vb = None
|
|
48
|
+
|
|
49
|
+
def get_camera_list():
|
|
50
|
+
return []
|
|
51
|
+
|
|
52
|
+
def get_camera(camera_id: Optional[str]):
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class vimba_cam(miCamera):
|
|
57
|
+
'''A class to handle an Allied Vision camera.'''
|
|
58
|
+
|
|
59
|
+
def __init__(self, camera_id=None):
|
|
60
|
+
super().__init__(camera_id)
|
|
61
|
+
|
|
62
|
+
self.vimba = vb.Vimba.get_instance()
|
|
63
|
+
self.cam = get_camera(camera_id)
|
|
64
|
+
self.Cam_ID = self.cam.get_id()
|
|
65
|
+
self.name = self.cam.get_name()
|
|
66
|
+
self.name = self.name.replace(' ', '_').replace('-', '_')
|
|
67
|
+
|
|
68
|
+
self.temperature = -127
|
|
69
|
+
|
|
70
|
+
self.exposure_current = 0
|
|
71
|
+
self.exposure_increment = 0.1
|
|
72
|
+
self.exposure_unit = 'us'
|
|
73
|
+
|
|
74
|
+
self.exposure_mode = 'Timed'
|
|
75
|
+
|
|
76
|
+
self.exposure_auto = 'Off'
|
|
77
|
+
|
|
78
|
+
self.frameRateEnabled = False
|
|
79
|
+
|
|
80
|
+
self.frameRate = 0.0
|
|
81
|
+
|
|
82
|
+
self.frameRate_increment = 1
|
|
83
|
+
self.frameRate_unit = ''
|
|
84
|
+
self.frameRate_range = None
|
|
85
|
+
|
|
86
|
+
self.trigger_source = 'Software'
|
|
87
|
+
|
|
88
|
+
self.trigger_selector = 'FrameStart'
|
|
89
|
+
|
|
90
|
+
self.trigger_source = 'On'
|
|
91
|
+
|
|
92
|
+
self.trigger_activation = ''
|
|
93
|
+
|
|
94
|
+
self.acquisition_mode = 'Continuous'
|
|
95
|
+
self.acquisition = False
|
|
96
|
+
|
|
97
|
+
self.pixel_format = None
|
|
98
|
+
self.pixel_size = None
|
|
99
|
+
self.bytes_per_pixel = 1
|
|
100
|
+
|
|
101
|
+
self.width = None
|
|
102
|
+
self.width_max = None
|
|
103
|
+
self.width_range = None
|
|
104
|
+
self.width_inc = None
|
|
105
|
+
self.height = None
|
|
106
|
+
self.height_max = None
|
|
107
|
+
self.height_range = None
|
|
108
|
+
self.height_inc = None
|
|
109
|
+
self.offsetX = None
|
|
110
|
+
self.offsetX_range = None
|
|
111
|
+
self.offsetX_inc = None
|
|
112
|
+
self.offsetY = None
|
|
113
|
+
self.offsetY_range = None
|
|
114
|
+
self.offsetY_inc = None
|
|
115
|
+
|
|
116
|
+
self.trigger_modes = []
|
|
117
|
+
self.trigger_sources = []
|
|
118
|
+
self.trigger_selectors = []
|
|
119
|
+
self.trigger_activations = []
|
|
120
|
+
|
|
121
|
+
self.exposure_modes = []
|
|
122
|
+
self.exposure_auto_entries = []
|
|
123
|
+
|
|
124
|
+
self.pixel_formats = []
|
|
125
|
+
|
|
126
|
+
self.initialize()
|
|
127
|
+
|
|
128
|
+
def initialize(self):
|
|
129
|
+
with self.cam:
|
|
130
|
+
self.default()
|
|
131
|
+
self.get_acquisition_framerate_enable(False)
|
|
132
|
+
self.get_framerate(False)
|
|
133
|
+
self.get_exposure(False)
|
|
134
|
+
self.get_exposure_mode(False)
|
|
135
|
+
self.get_exposure_auto(False)
|
|
136
|
+
self.get_trigger_source(False)
|
|
137
|
+
self.get_trigger_selector(False)
|
|
138
|
+
self.get_trigger_mode(False)
|
|
139
|
+
self.get_trigger_activation(False)
|
|
140
|
+
self.get_acquisition_mode(False)
|
|
141
|
+
self.get_pixel_format(False)
|
|
142
|
+
self.get_pixel_size(False)
|
|
143
|
+
self.get_roi(False)
|
|
144
|
+
self.get_temperature()
|
|
145
|
+
|
|
146
|
+
self.trigger_modes = self.get_trigger_modes()
|
|
147
|
+
self.trigger_sources = self.get_trigger_sources()
|
|
148
|
+
self.trigger_selectors = self.get_trigger_selectors()
|
|
149
|
+
self.trigger_activations = self.get_trigger_activations()
|
|
150
|
+
|
|
151
|
+
self.exposure_modes = self.get_exposure_modes()
|
|
152
|
+
self.exposure_auto_entries = self.get_exposure_auto_entries()
|
|
153
|
+
|
|
154
|
+
self.pixel_formats = self.get_pixel_formats()
|
|
155
|
+
|
|
156
|
+
self.print_status()
|
|
157
|
+
|
|
158
|
+
def populate_status(self):
|
|
159
|
+
self.status['Camera'] = {'Name': self.name}
|
|
160
|
+
|
|
161
|
+
self.status['Temperature'] = {'Value': self.temperature, 'Unit': 'Celsius'}
|
|
162
|
+
|
|
163
|
+
self.status['Exposure'] = {
|
|
164
|
+
'Mode': self.exposure_mode,
|
|
165
|
+
'Value': self.exposure_current,
|
|
166
|
+
'Unit': self.exposure_unit,
|
|
167
|
+
'Increment': self.exposure_increment,
|
|
168
|
+
'Auto': self.exposure_auto,
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
self.status['Framerate'] = {
|
|
172
|
+
'Value': self.frameRate,
|
|
173
|
+
'Unit': self.frameRate_unit,
|
|
174
|
+
'Range': self.frameRate_range,
|
|
175
|
+
'Increment': self.frameRate_increment,
|
|
176
|
+
'Enabled': self.frameRateEnabled,
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
self.status['Acquisition'] = {
|
|
180
|
+
'Mode': self.acquisition_mode,
|
|
181
|
+
'Enabled': self.acquisition,
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
# self.status['Trigger'] = {
|
|
185
|
+
# 'source': self.trigger_source,
|
|
186
|
+
# 'selector': self.trigger_selector,
|
|
187
|
+
# 'activation': self.trigger_activation,
|
|
188
|
+
# }
|
|
189
|
+
self.status['Image Format'] = {
|
|
190
|
+
'Pixel Format': self.pixel_format,
|
|
191
|
+
'Pixel Size': self.pixel_size,
|
|
192
|
+
'Bytes per Pixel': self.bytes_per_pixel,
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
self.status['Image Size'] = {
|
|
196
|
+
'Width': self.width,
|
|
197
|
+
'Width_max': self.width_max,
|
|
198
|
+
'Width_range': self.width_range,
|
|
199
|
+
'Width_inc': self.width_inc,
|
|
200
|
+
'Height': self.height,
|
|
201
|
+
'Height_max': self.height_max,
|
|
202
|
+
'Height_range': self.height_range,
|
|
203
|
+
'Height_inc': self.height_inc,
|
|
204
|
+
'Offset_x': self.offsetX,
|
|
205
|
+
'Offset_x_range': self.offsetX_range,
|
|
206
|
+
'Offset_x_inc': self.offsetX_inc,
|
|
207
|
+
'Offset_y': self.offsetY,
|
|
208
|
+
'Offset_y_range': self.offsetY_range,
|
|
209
|
+
'Offset_y_inc': self.offsetY_inc,
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
def default(self):
|
|
213
|
+
# with self.cam:
|
|
214
|
+
# Restore settings to initial value.
|
|
215
|
+
try:
|
|
216
|
+
self.cam.UserSetSelector.set('Default')
|
|
217
|
+
|
|
218
|
+
except (AttributeError, vb.VimbaFeatureError):
|
|
219
|
+
print("Failed to set Feature 'UserSetSelector'")
|
|
220
|
+
|
|
221
|
+
try:
|
|
222
|
+
self.cam.UserSetLoad.run()
|
|
223
|
+
print('--> All feature values have been restored to default')
|
|
224
|
+
|
|
225
|
+
except (AttributeError, vb.VimbaFeatureError):
|
|
226
|
+
print("Failed to run Feature 'UserSetLoad'")
|
|
227
|
+
|
|
228
|
+
def get_temperature(self):
|
|
229
|
+
'''Reads out the sensor temperature value
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
float
|
|
234
|
+
camera sensor temperature in C.
|
|
235
|
+
'''
|
|
236
|
+
self.temperature = -127
|
|
237
|
+
# with self.cam:
|
|
238
|
+
with contextlib.suppress(Exception):
|
|
239
|
+
self.temperature = self.cam.get_feature_by_name('DeviceTemperature').get()
|
|
240
|
+
return self.temperature
|
|
241
|
+
|
|
242
|
+
# Get exposure
|
|
243
|
+
def get_exposure(self, output=True):
|
|
244
|
+
exp = -127
|
|
245
|
+
try:
|
|
246
|
+
# with self.cam:
|
|
247
|
+
try:
|
|
248
|
+
exposure = self.cam.ExposureTime
|
|
249
|
+
self.exposure_current = exposure.get()
|
|
250
|
+
self.exposure_increment = exposure.get_increment()
|
|
251
|
+
self.exposure_unit = exposure.get_unit()
|
|
252
|
+
self.exposure_range = exposure.get_range()
|
|
253
|
+
except Exception:
|
|
254
|
+
exposure = self.cam.ExposureTimeAbs
|
|
255
|
+
self.exposure_current = exposure.get()
|
|
256
|
+
self.exposure_increment = self.cam.ExposureTimeIncrement.get()
|
|
257
|
+
self.exposure_unit = exposure.get_unit()
|
|
258
|
+
self.exposure_range = exposure.get_range()
|
|
259
|
+
if output:
|
|
260
|
+
print('Current Exposure ', self.exposure_current, self.exposure_unit)
|
|
261
|
+
return self.exposure_current
|
|
262
|
+
except Exception:
|
|
263
|
+
print('Exposure Get ERROR')
|
|
264
|
+
return exp
|
|
265
|
+
|
|
266
|
+
def set_exposure(self, value: float):
|
|
267
|
+
try:
|
|
268
|
+
# with self.cam:
|
|
269
|
+
try:
|
|
270
|
+
exposure = self.cam.ExposureTime
|
|
271
|
+
self.exposure_increment = exposure.get_increment()
|
|
272
|
+
self.exposure_unit = exposure.get_unit()
|
|
273
|
+
self.exposure_range = exposure.get_range()
|
|
274
|
+
except Exception:
|
|
275
|
+
exposure = self.cam.ExposureTimeAbs
|
|
276
|
+
self.exposure_increment = self.cam.ExposureTimeIncrement.get()
|
|
277
|
+
self.exposure_unit = exposure.get_unit()
|
|
278
|
+
self.exposure_range = exposure.get_range()
|
|
279
|
+
floor_value = (
|
|
280
|
+
self.exposure_increment
|
|
281
|
+
* np.floor((value - self.exposure_range[0]) / self.exposure_increment)
|
|
282
|
+
+ self.exposure_range[0]
|
|
283
|
+
)
|
|
284
|
+
ceil_value = (
|
|
285
|
+
self.exposure_increment
|
|
286
|
+
* np.ceil((value - self.exposure_range[0]) / self.exposure_increment)
|
|
287
|
+
+ self.exposure_range[0]
|
|
288
|
+
)
|
|
289
|
+
set_value = 0
|
|
290
|
+
if np.abs(floor_value - value) < np.abs(ceil_value - value):
|
|
291
|
+
set_value = floor_value
|
|
292
|
+
else:
|
|
293
|
+
set_value = ceil_value
|
|
294
|
+
set_value = max(
|
|
295
|
+
min(set_value, self.exposure_range[1]), self.exposure_range[0]
|
|
296
|
+
)
|
|
297
|
+
exposure.set(set_value)
|
|
298
|
+
self.get_exposure()
|
|
299
|
+
self.get_framerate()
|
|
300
|
+
return 1
|
|
301
|
+
except Exception:
|
|
302
|
+
print('Exposure Set ERROR')
|
|
303
|
+
return 0
|
|
304
|
+
|
|
305
|
+
def set_black_level(self, value: float):
|
|
306
|
+
try:
|
|
307
|
+
blackLevel = self.cam.BlackLevel
|
|
308
|
+
blackLevel.set(value)
|
|
309
|
+
return 1
|
|
310
|
+
except Exception:
|
|
311
|
+
print('Black Level Set ERROR')
|
|
312
|
+
return 0
|
|
313
|
+
|
|
314
|
+
def set_exposure_mode(self, value: str = 'Timed'):
|
|
315
|
+
try:
|
|
316
|
+
# with self.cam:
|
|
317
|
+
ExposureMode = self.cam.ExposureMode
|
|
318
|
+
entries = map(str, ExposureMode.get_available_entries())
|
|
319
|
+
if value in entries:
|
|
320
|
+
ExposureMode.set(value)
|
|
321
|
+
return 1
|
|
322
|
+
except Exception:
|
|
323
|
+
print('ExposureMode Set ERROR')
|
|
324
|
+
return 0
|
|
325
|
+
|
|
326
|
+
def get_exposure_mode(self, output=True):
|
|
327
|
+
try:
|
|
328
|
+
# with self.cam:
|
|
329
|
+
ExposureMode = self.cam.ExposureMode
|
|
330
|
+
self.exposure_mode = ExposureMode.get()
|
|
331
|
+
if output:
|
|
332
|
+
print('Exposure mode ', self.exposure_mode)
|
|
333
|
+
return self.exposure_mode
|
|
334
|
+
except Exception:
|
|
335
|
+
print('ExposureMode get ERROR')
|
|
336
|
+
return 'NA'
|
|
337
|
+
|
|
338
|
+
def get_exposure_modes(self):
|
|
339
|
+
modes = []
|
|
340
|
+
displayNames = []
|
|
341
|
+
tooltips = []
|
|
342
|
+
|
|
343
|
+
try:
|
|
344
|
+
# with self.cam:
|
|
345
|
+
ExposureMode = self.cam.ExposureMode
|
|
346
|
+
entries = ExposureMode.get_available_entries()
|
|
347
|
+
modes += map(str, entries)
|
|
348
|
+
displayNames += [entry._EnumEntry__info.displayName for entry in entries]
|
|
349
|
+
tooltips += [entry._EnumEntry__info.tooltip for entry in entries]
|
|
350
|
+
except Exception:
|
|
351
|
+
print('ExposureModes Get ERROR')
|
|
352
|
+
|
|
353
|
+
return [modes, displayNames, tooltips]
|
|
354
|
+
|
|
355
|
+
def set_exposure_auto(self, value: str = 'Off'):
|
|
356
|
+
try:
|
|
357
|
+
# with self.cam:
|
|
358
|
+
ExposureAuto = self.cam.ExposureAuto
|
|
359
|
+
entries = map(str, ExposureAuto.get_available_entries())
|
|
360
|
+
if value in entries:
|
|
361
|
+
ExposureAuto.set(value)
|
|
362
|
+
return 1
|
|
363
|
+
else:
|
|
364
|
+
return 0
|
|
365
|
+
except Exception:
|
|
366
|
+
print('ExposureAuto Set ERROR')
|
|
367
|
+
return 0
|
|
368
|
+
|
|
369
|
+
def get_exposure_auto(self, output=True):
|
|
370
|
+
try:
|
|
371
|
+
# with self.cam:
|
|
372
|
+
ExposureAuto = self.cam.ExposureAuto
|
|
373
|
+
self.exposure_auto = ExposureAuto.get()
|
|
374
|
+
if output:
|
|
375
|
+
print('Exposure Auto ', self.exposure_auto)
|
|
376
|
+
return self.exposure_auto
|
|
377
|
+
except Exception:
|
|
378
|
+
print('ExposureAuto get ERROR')
|
|
379
|
+
return 'NA'
|
|
380
|
+
|
|
381
|
+
def get_exposure_auto_entries(self):
|
|
382
|
+
modes = []
|
|
383
|
+
displayNames = []
|
|
384
|
+
tooltips = []
|
|
385
|
+
|
|
386
|
+
try:
|
|
387
|
+
# with self.cam:
|
|
388
|
+
ExposureAuto = self.cam.ExposureAuto
|
|
389
|
+
entries = ExposureAuto.get_available_entries()
|
|
390
|
+
modes += map(str, entries)
|
|
391
|
+
displayNames += [entry._EnumEntry__info.displayName for entry in entries]
|
|
392
|
+
tooltips += [entry._EnumEntry__info.tooltip for entry in entries]
|
|
393
|
+
except Exception:
|
|
394
|
+
print('ExposureAutos Get ERROR')
|
|
395
|
+
|
|
396
|
+
return [modes, displayNames, tooltips]
|
|
397
|
+
|
|
398
|
+
def set_acquisition_framerate_enable(self, enabled: bool = False):
|
|
399
|
+
try:
|
|
400
|
+
AcquisitionFrameRateEnable = self.cam.AcquisitionFrameRateEnable
|
|
401
|
+
AcquisitionFrameRateEnable.set(enabled)
|
|
402
|
+
self.frameRateEnabled = enabled
|
|
403
|
+
except Exception:
|
|
404
|
+
print('AcquisitionFrameRateEnable set ERROR')
|
|
405
|
+
|
|
406
|
+
def get_acquisition_framerate_enable(self, output: bool = True):
|
|
407
|
+
try:
|
|
408
|
+
AcquisitionFrameRateEnable = self.cam.AcquisitionFrameRateEnable
|
|
409
|
+
self.frameRateEnabled = AcquisitionFrameRateEnable.get()
|
|
410
|
+
if output:
|
|
411
|
+
print('AcquisitionFrameRate Enabled ', self.frameRateEnabled)
|
|
412
|
+
except Exception:
|
|
413
|
+
print('AcquisitionFrameRateEnable get ERROR')
|
|
414
|
+
|
|
415
|
+
def get_framerate(self, output: bool = True):
|
|
416
|
+
try:
|
|
417
|
+
frameRate = self.cam.AcquisitionFrameRate
|
|
418
|
+
self.frameRate = frameRate.get()
|
|
419
|
+
self.frameRate_unit = frameRate.get_unit()
|
|
420
|
+
self.frameRate_range = frameRate.get_range()
|
|
421
|
+
if output:
|
|
422
|
+
print('Current FrameRate ', self.frameRate, self.frameRate_unit)
|
|
423
|
+
return self.frameRate
|
|
424
|
+
except Exception:
|
|
425
|
+
print('AcquisitionFrameRate get ERROR')
|
|
426
|
+
self.frameRate = 0.0
|
|
427
|
+
return self.frameRate
|
|
428
|
+
|
|
429
|
+
def set_framerate(self, value: float):
|
|
430
|
+
if not self.frameRateEnabled:
|
|
431
|
+
return 0
|
|
432
|
+
|
|
433
|
+
try:
|
|
434
|
+
frameRate = self.cam.AcquisitionFrameRate
|
|
435
|
+
self.frameRate_unit = frameRate.get_unit()
|
|
436
|
+
self.frameRate_range = frameRate.get_range()
|
|
437
|
+
|
|
438
|
+
set_value = max(
|
|
439
|
+
min(value, self.frameRate_range[1]), self.frameRate_range[0]
|
|
440
|
+
)
|
|
441
|
+
frameRate.set(set_value)
|
|
442
|
+
self.get_framerate(False)
|
|
443
|
+
self.get_exposure(False)
|
|
444
|
+
return 1
|
|
445
|
+
except Exception:
|
|
446
|
+
print('AcquisitionFrameRate Set ERROR')
|
|
447
|
+
return 0
|
|
448
|
+
|
|
449
|
+
def set_trigger_mode(self, value: str = 'On'):
|
|
450
|
+
try:
|
|
451
|
+
# with self.cam:
|
|
452
|
+
TriggerMode = self.cam.TriggerMode
|
|
453
|
+
entries = map(str, TriggerMode.get_available_entries())
|
|
454
|
+
if value in entries:
|
|
455
|
+
TriggerMode.set(value)
|
|
456
|
+
return 1
|
|
457
|
+
else:
|
|
458
|
+
return 0
|
|
459
|
+
except Exception:
|
|
460
|
+
print('trigger Set ERROR')
|
|
461
|
+
return 0
|
|
462
|
+
|
|
463
|
+
def get_trigger_mode(self, output=True):
|
|
464
|
+
try:
|
|
465
|
+
# with self.cam:
|
|
466
|
+
TriggerMode = self.cam.TriggerMode
|
|
467
|
+
self.trigger_mode = TriggerMode.get()
|
|
468
|
+
if output:
|
|
469
|
+
print('Trigger mode ', self.trigger_mode)
|
|
470
|
+
return self.trigger_mode
|
|
471
|
+
except Exception:
|
|
472
|
+
print('trigger get ERROR')
|
|
473
|
+
return 'NA'
|
|
474
|
+
|
|
475
|
+
def get_trigger_modes(self):
|
|
476
|
+
modes = []
|
|
477
|
+
displayNames = []
|
|
478
|
+
tooltips = []
|
|
479
|
+
|
|
480
|
+
try:
|
|
481
|
+
# with self.cam:
|
|
482
|
+
TriggerMode = self.cam.TriggerMode
|
|
483
|
+
entries = TriggerMode.get_available_entries()
|
|
484
|
+
modes += map(str, entries)
|
|
485
|
+
displayNames += [entry._EnumEntry__info.displayName for entry in entries]
|
|
486
|
+
tooltips += [entry._EnumEntry__info.tooltip for entry in entries]
|
|
487
|
+
except Exception:
|
|
488
|
+
print('trigger modes Get ERROR')
|
|
489
|
+
|
|
490
|
+
return [modes, displayNames, tooltips]
|
|
491
|
+
|
|
492
|
+
def set_trigger_source(self, value: str = 'Software'):
|
|
493
|
+
try:
|
|
494
|
+
# with self.cam:
|
|
495
|
+
TriggerSource = self.cam.TriggerSource
|
|
496
|
+
entries = map(str, TriggerSource.get_available_entries())
|
|
497
|
+
if value in entries:
|
|
498
|
+
TriggerSource.set(value)
|
|
499
|
+
return 1
|
|
500
|
+
else:
|
|
501
|
+
return 0
|
|
502
|
+
except Exception:
|
|
503
|
+
print('trigger source Set ERROR')
|
|
504
|
+
return 0
|
|
505
|
+
|
|
506
|
+
def get_trigger_source(self, output=True):
|
|
507
|
+
try:
|
|
508
|
+
# with self.cam:
|
|
509
|
+
TriggerSource = self.cam.TriggerSource
|
|
510
|
+
self.trigger_source = TriggerSource.get()
|
|
511
|
+
if output:
|
|
512
|
+
print('Trigger source ', self.trigger_source)
|
|
513
|
+
return self.trigger_source
|
|
514
|
+
except Exception:
|
|
515
|
+
print('trigger source get ERROR')
|
|
516
|
+
return 'NA'
|
|
517
|
+
|
|
518
|
+
def get_trigger_sources(self):
|
|
519
|
+
sources = []
|
|
520
|
+
displayNames = []
|
|
521
|
+
tooltips = []
|
|
522
|
+
|
|
523
|
+
try:
|
|
524
|
+
# with self.cam:
|
|
525
|
+
TriggerSource = self.cam.TriggerSource
|
|
526
|
+
entries = TriggerSource.get_available_entries()
|
|
527
|
+
sources += map(str, entries)
|
|
528
|
+
displayNames += [entry._EnumEntry__info.displayName for entry in entries]
|
|
529
|
+
tooltips += [entry._EnumEntry__info.tooltip for entry in entries]
|
|
530
|
+
except Exception:
|
|
531
|
+
print('trigger sources Get ERROR')
|
|
532
|
+
|
|
533
|
+
return [sources, displayNames, tooltips]
|
|
534
|
+
|
|
535
|
+
def set_trigger_selector(self, value: str = 'FrameStart'):
|
|
536
|
+
try:
|
|
537
|
+
# with self.cam:
|
|
538
|
+
TriggerSelector = self.cam.TriggerSelector
|
|
539
|
+
entries = map(str, TriggerSelector.get_available_entries())
|
|
540
|
+
if value in entries:
|
|
541
|
+
TriggerSelector.set(value)
|
|
542
|
+
return 1
|
|
543
|
+
else:
|
|
544
|
+
return 0
|
|
545
|
+
except Exception:
|
|
546
|
+
print('trigger selector Set ERROR')
|
|
547
|
+
return 0
|
|
548
|
+
|
|
549
|
+
def get_trigger_selector(self, output=True):
|
|
550
|
+
try:
|
|
551
|
+
# with self.cam:
|
|
552
|
+
TriggerSelector = self.cam.TriggerSelector
|
|
553
|
+
self.trigger_selector = TriggerSelector.get()
|
|
554
|
+
if output:
|
|
555
|
+
print('Trigger selector ', self.trigger_selector)
|
|
556
|
+
return self.trigger_selector
|
|
557
|
+
except Exception:
|
|
558
|
+
print('trigger selector get ERROR')
|
|
559
|
+
return 'NA'
|
|
560
|
+
|
|
561
|
+
def get_trigger_selectors(self):
|
|
562
|
+
selectors = []
|
|
563
|
+
displayNames = []
|
|
564
|
+
tooltips = []
|
|
565
|
+
try:
|
|
566
|
+
# with self.cam:
|
|
567
|
+
TriggerSelector = self.cam.TriggerSelector
|
|
568
|
+
entries = TriggerSelector.get_available_entries()
|
|
569
|
+
selectors += map(str, entries)
|
|
570
|
+
displayNames += [entry._EnumEntry__info.displayName for entry in entries]
|
|
571
|
+
tooltips += [entry._EnumEntry__info.tooltip for entry in entries]
|
|
572
|
+
except Exception:
|
|
573
|
+
print('trigger selectors Get ERROR')
|
|
574
|
+
|
|
575
|
+
return [selectors, displayNames, tooltips]
|
|
576
|
+
|
|
577
|
+
def set_trigger_activation(self, value: str = 'RisingEdge'):
|
|
578
|
+
try:
|
|
579
|
+
# with self.cam:
|
|
580
|
+
TriggerActivation = self.cam.TriggerActivation
|
|
581
|
+
entries = map(str, TriggerActivation.get_available_entries())
|
|
582
|
+
if value in entries:
|
|
583
|
+
TriggerActivation.set(value)
|
|
584
|
+
return 1
|
|
585
|
+
else:
|
|
586
|
+
return 0
|
|
587
|
+
except Exception:
|
|
588
|
+
print('TriggerActivation Set ERROR')
|
|
589
|
+
return 0
|
|
590
|
+
|
|
591
|
+
def get_trigger_activation(self, output=True):
|
|
592
|
+
try:
|
|
593
|
+
# with self.cam:
|
|
594
|
+
TriggerActivation = self.cam.TriggerActivation
|
|
595
|
+
self.trigger_activation = TriggerActivation.get()
|
|
596
|
+
if output:
|
|
597
|
+
print('Trigger activation ', self.trigger_activation)
|
|
598
|
+
return self.trigger_activation
|
|
599
|
+
except Exception:
|
|
600
|
+
print('TriggerActivation get ERROR')
|
|
601
|
+
return 'NA'
|
|
602
|
+
|
|
603
|
+
def get_trigger_activations(self):
|
|
604
|
+
activations = []
|
|
605
|
+
displayNames = []
|
|
606
|
+
tooltips = []
|
|
607
|
+
try:
|
|
608
|
+
# with self.cam:
|
|
609
|
+
TriggerActivation = self.cam.TriggerActivation
|
|
610
|
+
entries = TriggerActivation.get_available_entries()
|
|
611
|
+
activations += map(str, entries)
|
|
612
|
+
displayNames += [entry._EnumEntry__info.displayName for entry in entries]
|
|
613
|
+
tooltips += [entry._EnumEntry__info.tooltip for entry in entries]
|
|
614
|
+
except Exception:
|
|
615
|
+
print('TriggerActivation Get ERROR')
|
|
616
|
+
|
|
617
|
+
return [activations, displayNames, tooltips]
|
|
618
|
+
|
|
619
|
+
def set_acquisition_mode(self, value: str = 'Continuous'):
|
|
620
|
+
try:
|
|
621
|
+
# with self.cam:
|
|
622
|
+
AcquisitionMode = self.cam.AcquisitionMode
|
|
623
|
+
entries = map(str, AcquisitionMode.get_available_entries())
|
|
624
|
+
if value in entries:
|
|
625
|
+
AcquisitionMode.set(value)
|
|
626
|
+
return 1
|
|
627
|
+
else:
|
|
628
|
+
return 0
|
|
629
|
+
except Exception:
|
|
630
|
+
print('AcquisitionMode Set ERROR')
|
|
631
|
+
return 0
|
|
632
|
+
|
|
633
|
+
def get_acquisition_mode(self, output=True):
|
|
634
|
+
try:
|
|
635
|
+
# with self.cam:
|
|
636
|
+
AcquisitionMode = self.cam.AcquisitionMode
|
|
637
|
+
self.acquisition_mode = AcquisitionMode.get()
|
|
638
|
+
if output:
|
|
639
|
+
print('Acquisition mode ', self.acquisition_mode)
|
|
640
|
+
return self.acquisition_mode
|
|
641
|
+
except Exception:
|
|
642
|
+
print('AcquisitionMode get ERROR')
|
|
643
|
+
return 'NA'
|
|
644
|
+
|
|
645
|
+
def get_acquisition_modes(self):
|
|
646
|
+
modes = []
|
|
647
|
+
displayNames = []
|
|
648
|
+
tooltips = []
|
|
649
|
+
try:
|
|
650
|
+
# with self.cam:
|
|
651
|
+
AcquisitionMode = self.cam.AcquisitionMode
|
|
652
|
+
entries = AcquisitionMode.get_available_entries()
|
|
653
|
+
modes += map(str, entries)
|
|
654
|
+
displayNames += [entry._EnumEntry__info.displayName for entry in entries]
|
|
655
|
+
tooltips += [entry._EnumEntry__info.tooltip for entry in entries]
|
|
656
|
+
except Exception:
|
|
657
|
+
print('AcquisitionModes Get ERROR')
|
|
658
|
+
|
|
659
|
+
return [modes, displayNames, tooltips]
|
|
660
|
+
|
|
661
|
+
def get_pixel_formats(self):
|
|
662
|
+
formats = []
|
|
663
|
+
try:
|
|
664
|
+
# with self.cam:
|
|
665
|
+
fmts = self.cam.get_pixel_formats()
|
|
666
|
+
formats += map(str, fmts)
|
|
667
|
+
except Exception:
|
|
668
|
+
print('Pixel Formats Get ERROR')
|
|
669
|
+
|
|
670
|
+
return formats
|
|
671
|
+
|
|
672
|
+
def get_pixel_format(self, output=True):
|
|
673
|
+
formats = []
|
|
674
|
+
try:
|
|
675
|
+
# with self.cam:
|
|
676
|
+
self.pixel_format = self.cam.get_pixel_format()
|
|
677
|
+
if output:
|
|
678
|
+
print('Pixel Format', self.pixel_format)
|
|
679
|
+
return self.pixel_format
|
|
680
|
+
except Exception:
|
|
681
|
+
print('Pixel Format Get ERROR')
|
|
682
|
+
return 'NA'
|
|
683
|
+
|
|
684
|
+
def set_pixel_format(self, value: str):
|
|
685
|
+
try:
|
|
686
|
+
# with self.cam:
|
|
687
|
+
if value in vb.PixelFormat.__members__:
|
|
688
|
+
self.cam.set_pixel_format(vb.PixelFormat[value])
|
|
689
|
+
self.get_pixel_size()
|
|
690
|
+
return 1
|
|
691
|
+
else:
|
|
692
|
+
return 0
|
|
693
|
+
except Exception:
|
|
694
|
+
pFormat = str(self.cam.get_pixel_format())
|
|
695
|
+
if '8' in pFormat:
|
|
696
|
+
self.pixel_size = 8
|
|
697
|
+
self.bytes_per_pixel = 1
|
|
698
|
+
return self.pixel_size
|
|
699
|
+
elif '12p' in pFormat:
|
|
700
|
+
print('Pixel Format Not supported.')
|
|
701
|
+
return 'NA'
|
|
702
|
+
elif '12' in pFormat:
|
|
703
|
+
self.pixel_size = 16
|
|
704
|
+
self.bytes_per_pixel = 2
|
|
705
|
+
return self.pixel_size
|
|
706
|
+
else:
|
|
707
|
+
print('Pixel Format Not supported.')
|
|
708
|
+
return 'NA'
|
|
709
|
+
finally:
|
|
710
|
+
self.set_black_level(5.0)
|
|
711
|
+
|
|
712
|
+
def get_pixel_size(self, output=True):
|
|
713
|
+
try:
|
|
714
|
+
# with self.cam:
|
|
715
|
+
self.pixel_size = self.cam.PixelSize.get()
|
|
716
|
+
self.bytes_per_pixel = int(np.ceil(int(self.pixel_size) / 8))
|
|
717
|
+
if output:
|
|
718
|
+
print('Pixel Size', self.pixel_size)
|
|
719
|
+
return self.pixel_size
|
|
720
|
+
except Exception:
|
|
721
|
+
print('Pixel Size Get ERROR')
|
|
722
|
+
return 'NA'
|
|
723
|
+
|
|
724
|
+
def get_io_lines(self):
|
|
725
|
+
try:
|
|
726
|
+
lines = []
|
|
727
|
+
for line in self.cam.LineSelector.get_available_entries():
|
|
728
|
+
lines.append(str(line))
|
|
729
|
+
return lines
|
|
730
|
+
except Exception:
|
|
731
|
+
print('get_io_lines ERROR')
|
|
732
|
+
return None
|
|
733
|
+
|
|
734
|
+
def get_line_modes(self):
|
|
735
|
+
try:
|
|
736
|
+
modes = []
|
|
737
|
+
for mode in self.cam.LineMode.get_available_entries():
|
|
738
|
+
modes.append(str(mode))
|
|
739
|
+
return modes
|
|
740
|
+
except Exception:
|
|
741
|
+
print('get_line_modes ERROR')
|
|
742
|
+
return None
|
|
743
|
+
|
|
744
|
+
def get_line_sources(self):
|
|
745
|
+
try:
|
|
746
|
+
sources = []
|
|
747
|
+
for source in self.cam.LineSource.get_available_entries():
|
|
748
|
+
sources.append(str(source))
|
|
749
|
+
return sources
|
|
750
|
+
except Exception:
|
|
751
|
+
print('get_line_sources ERROR')
|
|
752
|
+
return None
|
|
753
|
+
|
|
754
|
+
def get_line_source(self):
|
|
755
|
+
try:
|
|
756
|
+
return str(self.cam.LineSource.get())
|
|
757
|
+
except Exception:
|
|
758
|
+
print('get_line_source ERROR')
|
|
759
|
+
return None
|
|
760
|
+
|
|
761
|
+
def get_line_mode(self):
|
|
762
|
+
try:
|
|
763
|
+
return str(self.cam.LineMode.get())
|
|
764
|
+
except Exception:
|
|
765
|
+
print('get_line_mode ERROR')
|
|
766
|
+
return None
|
|
767
|
+
|
|
768
|
+
def get_line_inverter(self):
|
|
769
|
+
try:
|
|
770
|
+
return self.cam.LineInverter.get()
|
|
771
|
+
except Exception:
|
|
772
|
+
print('get_line_inverter ERROR')
|
|
773
|
+
return None
|
|
774
|
+
|
|
775
|
+
def get_line_status(self):
|
|
776
|
+
try:
|
|
777
|
+
return self.cam.LineStatus.get()
|
|
778
|
+
except Exception:
|
|
779
|
+
print('get_line_status ERROR')
|
|
780
|
+
return None
|
|
781
|
+
|
|
782
|
+
def set_line_inverter(self, value: bool):
|
|
783
|
+
try:
|
|
784
|
+
self.cam.LineInverter.set(value)
|
|
785
|
+
return True
|
|
786
|
+
except Exception:
|
|
787
|
+
print('set_line_inverter ERROR')
|
|
788
|
+
return False
|
|
789
|
+
|
|
790
|
+
def set_line_source(self, value: str):
|
|
791
|
+
try:
|
|
792
|
+
self.cam.LineSource.set(value)
|
|
793
|
+
return True
|
|
794
|
+
except Exception:
|
|
795
|
+
print('set_line_source ERROR')
|
|
796
|
+
return False
|
|
797
|
+
|
|
798
|
+
def set_line_mode(self, value: str):
|
|
799
|
+
try:
|
|
800
|
+
self.cam.LineMode.set(value)
|
|
801
|
+
return True
|
|
802
|
+
except Exception:
|
|
803
|
+
print('set_line_mode ERROR')
|
|
804
|
+
return False
|
|
805
|
+
|
|
806
|
+
def select_io_line(self, value: str):
|
|
807
|
+
try:
|
|
808
|
+
self.cam.LineSelector.set(value)
|
|
809
|
+
return True
|
|
810
|
+
except Exception:
|
|
811
|
+
print('select_io_line ERROR')
|
|
812
|
+
return False
|
|
813
|
+
|
|
814
|
+
def get_timers(self):
|
|
815
|
+
try:
|
|
816
|
+
timers = []
|
|
817
|
+
for timer in self.cam.TimerSelector.get_available_entries():
|
|
818
|
+
timers.append(str(timer))
|
|
819
|
+
return timers
|
|
820
|
+
except Exception:
|
|
821
|
+
print('get_timers ERROR')
|
|
822
|
+
return None
|
|
823
|
+
|
|
824
|
+
def get_timer_trigger_activations(self):
|
|
825
|
+
try:
|
|
826
|
+
modes = []
|
|
827
|
+
for mode in self.cam.TimerTriggerActivation.get_available_entries():
|
|
828
|
+
modes.append(str(mode))
|
|
829
|
+
return modes
|
|
830
|
+
except Exception:
|
|
831
|
+
print('get_timer_trigger_activations ERROR')
|
|
832
|
+
return None
|
|
833
|
+
|
|
834
|
+
def get_timer_trigger_sources(self):
|
|
835
|
+
try:
|
|
836
|
+
sources = []
|
|
837
|
+
for source in self.cam.TimerTriggerSource.get_available_entries():
|
|
838
|
+
sources.append(str(source))
|
|
839
|
+
return sources
|
|
840
|
+
except Exception:
|
|
841
|
+
print('get_timer_trigger_sources ERROR')
|
|
842
|
+
return None
|
|
843
|
+
|
|
844
|
+
def get_timer_trigger_source(self):
|
|
845
|
+
try:
|
|
846
|
+
return str(self.cam.TimerTriggerSource.get())
|
|
847
|
+
except Exception:
|
|
848
|
+
print('get_timer_trigger_source ERROR')
|
|
849
|
+
return None
|
|
850
|
+
|
|
851
|
+
def get_timer_trigger_activation(self):
|
|
852
|
+
try:
|
|
853
|
+
return str(self.cam.TimerTriggerActivation.get())
|
|
854
|
+
except Exception:
|
|
855
|
+
print('get_timer_trigger_activation ERROR')
|
|
856
|
+
return None
|
|
857
|
+
|
|
858
|
+
def get_timer_status(self):
|
|
859
|
+
try:
|
|
860
|
+
return self.cam.TimerStatus.get()
|
|
861
|
+
except Exception:
|
|
862
|
+
print('get_timer_status ERROR')
|
|
863
|
+
return None
|
|
864
|
+
|
|
865
|
+
def set_timer_trigger_source(self, value: str):
|
|
866
|
+
try:
|
|
867
|
+
self.cam.TimerTriggerSource.set(value)
|
|
868
|
+
return True
|
|
869
|
+
except Exception:
|
|
870
|
+
print('set_timer_trigger_source ERROR')
|
|
871
|
+
return False
|
|
872
|
+
|
|
873
|
+
def set_timer_trigger_activation(self, value: str):
|
|
874
|
+
try:
|
|
875
|
+
self.cam.TimerTriggerActivation.set(value)
|
|
876
|
+
return True
|
|
877
|
+
except Exception:
|
|
878
|
+
print('set_line_mode ERROR')
|
|
879
|
+
return False
|
|
880
|
+
|
|
881
|
+
def get_timer_duration(self):
|
|
882
|
+
try:
|
|
883
|
+
duration = self.cam.TimerDuration
|
|
884
|
+
return duration.get(), duration.get_range()
|
|
885
|
+
except Exception:
|
|
886
|
+
print('get_timer_duration ERROR')
|
|
887
|
+
|
|
888
|
+
def get_timer_delay(self):
|
|
889
|
+
try:
|
|
890
|
+
delay = self.cam.TimerDelay
|
|
891
|
+
return delay.get(), delay.get_range()
|
|
892
|
+
except Exception:
|
|
893
|
+
print('get_timer_delay ERROR')
|
|
894
|
+
|
|
895
|
+
def set_timer_duration(self, value: float):
|
|
896
|
+
try:
|
|
897
|
+
self.cam.TimerDuration.set(value)
|
|
898
|
+
return True
|
|
899
|
+
except Exception:
|
|
900
|
+
print('set_timer_duration ERROR')
|
|
901
|
+
return False
|
|
902
|
+
|
|
903
|
+
def set_timer_delay(self, value: float):
|
|
904
|
+
try:
|
|
905
|
+
self.cam.TimerDelay.set(value)
|
|
906
|
+
return True
|
|
907
|
+
except Exception:
|
|
908
|
+
print('set_timer_delay ERROR')
|
|
909
|
+
return False
|
|
910
|
+
|
|
911
|
+
def select_timer(self, value: str):
|
|
912
|
+
try:
|
|
913
|
+
self.cam.TimerSelector.set(value)
|
|
914
|
+
return True
|
|
915
|
+
except Exception:
|
|
916
|
+
print('select_timer ERROR')
|
|
917
|
+
return False
|
|
918
|
+
|
|
919
|
+
def reset_timer(self):
|
|
920
|
+
try:
|
|
921
|
+
self.cam.TimerReset.run()
|
|
922
|
+
return True
|
|
923
|
+
except Exception:
|
|
924
|
+
print('reset_timer ERROR')
|
|
925
|
+
return False
|
|
926
|
+
|
|
927
|
+
def get_roi(self, output=True):
|
|
928
|
+
try:
|
|
929
|
+
# with self.cam:
|
|
930
|
+
self.width = self.cam.Width.get()
|
|
931
|
+
self.width_max = self.cam.WidthMax.get()
|
|
932
|
+
self.width_range = self.cam.Width.get_range()
|
|
933
|
+
self.width_inc = self.cam.Width.get_increment()
|
|
934
|
+
self.height = self.cam.Height.get()
|
|
935
|
+
self.height_max = self.cam.HeightMax.get()
|
|
936
|
+
self.height_range = self.cam.Height.get_range()
|
|
937
|
+
self.height_inc = self.cam.Height.get_increment()
|
|
938
|
+
self.offsetX = self.cam.OffsetX.get()
|
|
939
|
+
self.offsetX_range = self.cam.OffsetX.get_range()
|
|
940
|
+
self.offsetX_inc = self.cam.OffsetX.get_increment()
|
|
941
|
+
self.offsetY = self.cam.OffsetY.get()
|
|
942
|
+
self.offsetY_range = self.cam.OffsetY.get_range()
|
|
943
|
+
self.offsetY_inc = self.cam.OffsetY.get_increment()
|
|
944
|
+
if output:
|
|
945
|
+
print('W H X Y', self.width, self.height, self.offsetX, self.offsetY)
|
|
946
|
+
return (self.width, self.height, self.offsetX, self.offsetY)
|
|
947
|
+
except Exception:
|
|
948
|
+
print('ROI Get ERROR')
|
|
949
|
+
return 'NA'
|
|
950
|
+
|
|
951
|
+
def set_roi(self, width, height, x=None, y=None):
|
|
952
|
+
try:
|
|
953
|
+
# with self.cam:
|
|
954
|
+
self.width_range = self.cam.Width.get_range()
|
|
955
|
+
self.width_inc = self.cam.Width.get_increment()
|
|
956
|
+
self.width = self.get_nearest(self.width_range, self.width_inc, width)
|
|
957
|
+
self.cam.Width.set(self.width)
|
|
958
|
+
|
|
959
|
+
self.height_range = self.cam.Height.get_range()
|
|
960
|
+
self.height_inc = self.cam.Height.get_increment()
|
|
961
|
+
self.height = self.get_nearest(self.height_range, self.height_inc, height)
|
|
962
|
+
self.cam.Height.set(self.height)
|
|
963
|
+
|
|
964
|
+
if x is None:
|
|
965
|
+
x = (self.width_range[1] - self.width) / 2
|
|
966
|
+
|
|
967
|
+
self.offsetX_range = self.cam.OffsetX.get_range()
|
|
968
|
+
self.offsetX_inc = self.cam.OffsetX.get_increment()
|
|
969
|
+
self.offsetX = self.get_nearest(self.offsetX_range, self.offsetX_inc, x)
|
|
970
|
+
self.cam.OffsetX.set(self.offsetX)
|
|
971
|
+
|
|
972
|
+
if y is None:
|
|
973
|
+
y = (self.height_range[1] - self.height) / 2
|
|
974
|
+
|
|
975
|
+
self.offsetY_range = self.cam.OffsetY.get_range()
|
|
976
|
+
self.offsetY_inc = self.cam.OffsetY.get_increment()
|
|
977
|
+
self.offsetY = self.get_nearest(self.offsetY_range, self.offsetY_inc, y)
|
|
978
|
+
self.cam.OffsetY.set(self.offsetY)
|
|
979
|
+
return 1
|
|
980
|
+
except Exception:
|
|
981
|
+
print('ROI Set ERROR')
|
|
982
|
+
return 0
|
|
983
|
+
|
|
984
|
+
def get_nearest(self, vrange, step, value):
|
|
985
|
+
values = np.arange(vrange[0], vrange[1] + step / 4, step)
|
|
986
|
+
return values[np.abs(values - value).argmin()]
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
# if __name__ == '__main__':
|
|
990
|
+
# camera = vimba_cam('')
|
|
991
|
+
|
|
992
|
+
# with camera.vimba, camera.cam:
|
|
993
|
+
# camera.set_exposure(-1)
|
|
994
|
+
# camera.get_exposure()
|
|
995
|
+
# camera.set_pixel_format('Mono12')
|
|
996
|
+
# camera.get_pixel_format()
|
|
997
|
+
# camera.set_trigger_mode()
|
|
998
|
+
# camera.set_roi(515, 515)
|
|
999
|
+
# camera.get_roi()
|
|
1000
|
+
# print(camera.get_pixel_formats())
|