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.
Files changed (190) hide show
  1. microEye/__init__.py +47 -0
  2. microEye/_version.py +2 -0
  3. microEye/analysis/__init__.py +1 -0
  4. microEye/analysis/checklist_dialog.py +143 -0
  5. microEye/analysis/cmosMaps.py +228 -0
  6. microEye/analysis/filters/__init__.py +9 -0
  7. microEye/analysis/filters/base.py +21 -0
  8. microEye/analysis/filters/spatial.py +338 -0
  9. microEye/analysis/filters/temporal.py +76 -0
  10. microEye/analysis/fitting/__init__.py +0 -0
  11. microEye/analysis/fitting/fit.py +680 -0
  12. microEye/analysis/fitting/nena.py +375 -0
  13. microEye/analysis/fitting/phasor_fit.py +90 -0
  14. microEye/analysis/fitting/processing.py +317 -0
  15. microEye/analysis/fitting/psf/__init__.py +6 -0
  16. microEye/analysis/fitting/psf/extract.py +1129 -0
  17. microEye/analysis/fitting/psf/rubost_mean.py +150 -0
  18. microEye/analysis/fitting/psf/spline.py +167 -0
  19. microEye/analysis/fitting/psf/stats/__init__.py +12 -0
  20. microEye/analysis/fitting/psf/stats/core.py +295 -0
  21. microEye/analysis/fitting/psf/stats/curve_fit.py +708 -0
  22. microEye/analysis/fitting/psf/stats/io.py +104 -0
  23. microEye/analysis/fitting/psf/stats/slope_fit.py +171 -0
  24. microEye/analysis/fitting/psf/temp.py +147 -0
  25. microEye/analysis/fitting/psf/test.py +47 -0
  26. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUfunctions.py +657 -0
  27. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUmleFit_LM.py +1336 -0
  28. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUsplineLib.py +270 -0
  29. microEye/analysis/fitting/pyfit3Dcspline/CPU/__init__.py +1 -0
  30. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUfunctions.py +609 -0
  31. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_EMCCD.py +1396 -0
  32. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_sCMOS.py +1426 -0
  33. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUsplineLib.py +231 -0
  34. microEye/analysis/fitting/pyfit3Dcspline/GPU/__init__.py +2 -0
  35. microEye/analysis/fitting/pyfit3Dcspline/__init__.py +10 -0
  36. microEye/analysis/fitting/pyfit3Dcspline/constants.py +27 -0
  37. microEye/analysis/fitting/pyfit3Dcspline/mainfunctions.py +903 -0
  38. microEye/analysis/fitting/results.py +917 -0
  39. microEye/analysis/fitting/results_stats.py +251 -0
  40. microEye/analysis/fitting/tardis.py +209 -0
  41. microEye/analysis/multi_viewer.py +568 -0
  42. microEye/analysis/processing/__init__.py +1 -0
  43. microEye/analysis/processing/frc.py +120 -0
  44. microEye/analysis/rendering/__init__.py +3 -0
  45. microEye/analysis/rendering/base.py +452 -0
  46. microEye/analysis/rendering/cloud.py +215 -0
  47. microEye/analysis/rendering/core.py +47 -0
  48. microEye/analysis/rendering/volumetric.py +198 -0
  49. microEye/analysis/tools/__init__.py +0 -0
  50. microEye/analysis/tools/kymograms.py +1079 -0
  51. microEye/analysis/tools/roi_selectors.py +556 -0
  52. microEye/analysis/utils/__init__.py +3 -0
  53. microEye/analysis/utils/coordinates.py +18 -0
  54. microEye/analysis/utils/images.py +68 -0
  55. microEye/analysis/utils/windows.py +19 -0
  56. microEye/analysis/viewer/__init__.py +3 -0
  57. microEye/analysis/viewer/image_options_widget.py +615 -0
  58. microEye/analysis/viewer/images.py +1225 -0
  59. microEye/analysis/viewer/layers_widget.py +415 -0
  60. microEye/analysis/viewer/localizations.py +1304 -0
  61. microEye/analysis/viewer/psf.py +1003 -0
  62. microEye/analysis/viewer/volume.py +456 -0
  63. microEye/hardware/__init__.py +3 -0
  64. microEye/hardware/cams/__init__.py +29 -0
  65. microEye/hardware/cams/camera_calibration.py +99 -0
  66. microEye/hardware/cams/camera_list.py +528 -0
  67. microEye/hardware/cams/camera_options.py +694 -0
  68. microEye/hardware/cams/camera_panel.py +941 -0
  69. microEye/hardware/cams/dummy/__init__.py +1 -0
  70. microEye/hardware/cams/dummy/dummy_panel.py +759 -0
  71. microEye/hardware/cams/jobs.py +497 -0
  72. microEye/hardware/cams/line_profiler.py +99 -0
  73. microEye/hardware/cams/linescan/IR_Cam.py +474 -0
  74. microEye/hardware/cams/linescan/__init__.py +1 -0
  75. microEye/hardware/cams/micam.py +524 -0
  76. microEye/hardware/cams/pco/__init__.py +58 -0
  77. microEye/hardware/cams/pco/enums.py +382 -0
  78. microEye/hardware/cams/pco/pco_cam.py +761 -0
  79. microEye/hardware/cams/pco/pco_panel.py +477 -0
  80. microEye/hardware/cams/shortcuts.py +312 -0
  81. microEye/hardware/cams/thorlabs/__init__.py +1 -0
  82. microEye/hardware/cams/thorlabs/thorlabs.py +1508 -0
  83. microEye/hardware/cams/thorlabs/thorlabs_panel.py +850 -0
  84. microEye/hardware/cams/ueye/__init__.py +1 -0
  85. microEye/hardware/cams/ueye/ueye_camera.py +1023 -0
  86. microEye/hardware/cams/ueye/ueye_panel.py +861 -0
  87. microEye/hardware/cams/vimba/__init__.py +1 -0
  88. microEye/hardware/cams/vimba/vimba_cam.py +1000 -0
  89. microEye/hardware/cams/vimba/vimba_panel.py +813 -0
  90. microEye/hardware/device.py +60 -0
  91. microEye/hardware/lasers/__init__.py +13 -0
  92. microEye/hardware/lasers/io_matchbox.py +791 -0
  93. microEye/hardware/lasers/io_params.py +85 -0
  94. microEye/hardware/lasers/io_single_laser.py +742 -0
  95. microEye/hardware/lasers/laser_relay.py +594 -0
  96. microEye/hardware/mieye/__init__.py +1 -0
  97. microEye/hardware/mieye/acquisition_manager.py +467 -0
  98. microEye/hardware/mieye/devices_manager.py +533 -0
  99. microEye/hardware/mieye/miEye.py +659 -0
  100. microEye/hardware/misc/__init__.py +0 -0
  101. microEye/hardware/misc/acquisition_view.py +71 -0
  102. microEye/hardware/misc/reglo.py +761 -0
  103. microEye/hardware/misc/temp.py +188 -0
  104. microEye/hardware/port_config.py +59 -0
  105. microEye/hardware/protocols/__init__.py +2 -0
  106. microEye/hardware/protocols/actions.py +402 -0
  107. microEye/hardware/protocols/actions_items.py +703 -0
  108. microEye/hardware/protocols/designer.py +244 -0
  109. microEye/hardware/protocols/scene_manager.py +191 -0
  110. microEye/hardware/protocols/serialization.py +97 -0
  111. microEye/hardware/pycromanager/__init__.py +16 -0
  112. microEye/hardware/pycromanager/core.py +1433 -0
  113. microEye/hardware/pycromanager/devices.py +461 -0
  114. microEye/hardware/pycromanager/enums.py +107 -0
  115. microEye/hardware/pycromanager/headless.py +153 -0
  116. microEye/hardware/pycromanager/utils.py +34 -0
  117. microEye/hardware/pycromanager/widgets/__init__.py +5 -0
  118. microEye/hardware/pycromanager/widgets/bridges.py +407 -0
  119. microEye/hardware/pycromanager/widgets/headless_manager.py +258 -0
  120. microEye/hardware/pycromanager/widgets/headless_options.py +224 -0
  121. microEye/hardware/pycromanager/widgets/pycro_panel.py +455 -0
  122. microEye/hardware/stages/__init__.py +18 -0
  123. microEye/hardware/stages/elliptec/__init__.py +5 -0
  124. microEye/hardware/stages/elliptec/baseDevice.py +314 -0
  125. microEye/hardware/stages/elliptec/device.py +384 -0
  126. microEye/hardware/stages/elliptec/deviceID.py +212 -0
  127. microEye/hardware/stages/elliptec/devicePort.py +379 -0
  128. microEye/hardware/stages/elliptec/deviceStatus.py +65 -0
  129. microEye/hardware/stages/elliptec/devicesView.py +706 -0
  130. microEye/hardware/stages/elliptec/ellDevices.py +134 -0
  131. microEye/hardware/stages/elliptec/messageUpdater.py +34 -0
  132. microEye/hardware/stages/elliptec/motorInfo.py +153 -0
  133. microEye/hardware/stages/elliptec/stage.py +62 -0
  134. microEye/hardware/stages/elliptec/test.py +139 -0
  135. microEye/hardware/stages/kinesis/__init__.py +1 -0
  136. microEye/hardware/stages/kinesis/kdc101/__init__.py +1 -0
  137. microEye/hardware/stages/kinesis/kdc101/enums.py +1002 -0
  138. microEye/hardware/stages/kinesis/kdc101/factory.py +171 -0
  139. microEye/hardware/stages/kinesis/kdc101/kdc101.py +718 -0
  140. microEye/hardware/stages/kinesis/kinesis.py +776 -0
  141. microEye/hardware/stages/piezo_concept.py +607 -0
  142. microEye/hardware/stages/stabilizer.py +785 -0
  143. microEye/hardware/stages/stage.py +89 -0
  144. microEye/hardware/widgets/__init__.py +10 -0
  145. microEye/hardware/widgets/controller.py +246 -0
  146. microEye/hardware/widgets/devices.py +133 -0
  147. microEye/hardware/widgets/focusWidget.py +264 -0
  148. microEye/hardware/widgets/qlist_slider.py +113 -0
  149. microEye/hardware/widgets/scan_acquisition.py +424 -0
  150. microEye/icons/1024.png +0 -0
  151. microEye/icons/128.png +0 -0
  152. microEye/icons/16.png +0 -0
  153. microEye/icons/24.png +0 -0
  154. microEye/icons/256.png +0 -0
  155. microEye/icons/32.png +0 -0
  156. microEye/icons/48.png +0 -0
  157. microEye/icons/512.png +0 -0
  158. microEye/icons/64.png +0 -0
  159. microEye/icons/__init__.py +0 -0
  160. microEye/icons/close.svg +88 -0
  161. microEye/icons/mieye.png +0 -0
  162. microEye/icons/min.svg +83 -0
  163. microEye/icons/viewer.png +0 -0
  164. microEye/launcher.py +42 -0
  165. microEye/qt.py +181 -0
  166. microEye/utils/__init__.py +2 -0
  167. microEye/utils/enum_encoder.py +10 -0
  168. microEye/utils/expandable_groupbox.py +93 -0
  169. microEye/utils/gui_helper.py +457 -0
  170. microEye/utils/hid/__init__.py +8 -0
  171. microEye/utils/hid/controller.py +153 -0
  172. microEye/utils/hid/device.py +63 -0
  173. microEye/utils/hid/enums.py +140 -0
  174. microEye/utils/hid/utils.py +58 -0
  175. microEye/utils/labelled_slider.py +134 -0
  176. microEye/utils/metadata.py +599 -0
  177. microEye/utils/metadata_tree.py +718 -0
  178. microEye/utils/micro_launcher.py +245 -0
  179. microEye/utils/parameter_tree.py +325 -0
  180. microEye/utils/pyscripting.py +444 -0
  181. microEye/utils/retry_exec.py +35 -0
  182. microEye/utils/start_gui.py +112 -0
  183. microEye/utils/thread_worker.py +115 -0
  184. microEye/utils/uImage.py +1512 -0
  185. microeye-2.3.2.dist-info/METADATA +401 -0
  186. microeye-2.3.2.dist-info/RECORD +190 -0
  187. microeye-2.3.2.dist-info/WHEEL +5 -0
  188. microeye-2.3.2.dist-info/entry_points.txt +2 -0
  189. microeye-2.3.2.dist-info/licenses/LICENSE +674 -0
  190. microeye-2.3.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1508 @@
1
+ import logging
2
+ import os.path
3
+ from ctypes import *
4
+
5
+ import numpy as np
6
+
7
+ from microEye.hardware.cams.micam import miCamera
8
+
9
+
10
+ class IS_SIZE_2D(Structure):
11
+ _fields_ = [('s32Width', c_int), ('s32Height', c_int)]
12
+
13
+
14
+ class IS_POINT_2D(Structure):
15
+ _fields_ = [('s32X', c_int), ('s32Y', c_int)]
16
+
17
+
18
+ class IS_RECT(Structure):
19
+ _pack_ = 8
20
+ _fields_ = [
21
+ ('s32X', c_int),
22
+ ('s32Y', c_int),
23
+ ('s32Width', c_int),
24
+ ('s32Height', c_int),
25
+ ]
26
+
27
+
28
+ class UC480_CAMERA_INFO(Structure):
29
+ _pack_ = 8
30
+ _fields_ = [
31
+ ('dwCameraID', c_uint),
32
+ ('dwDeviceID', c_uint),
33
+ ('dwSensorID', c_uint),
34
+ ('dwInUse', c_uint),
35
+ ('SerNo', (c_char * 16)),
36
+ ('Model', (c_char * 16)),
37
+ ('dwStatus', c_uint),
38
+ ('dwReserved', (c_uint * 2)),
39
+ ('FullModelName', (c_char * 32)),
40
+ ('dwReserved2', (c_uint * 5)),
41
+ ]
42
+
43
+
44
+ class BOARDINFO(Structure):
45
+ _pack_ = 8
46
+ _fields_ = [
47
+ ('SerNo', (c_char * 12)),
48
+ ('ID', (c_char * 20)),
49
+ ('Version', (c_char * 10)),
50
+ ('Date', (c_char * 12)),
51
+ ('Select', c_ubyte),
52
+ ('Type', c_ubyte),
53
+ ('Reserved', (c_char * 8)),
54
+ ]
55
+
56
+
57
+ class SENSORINFO(Structure):
58
+ _pack_ = 8
59
+ _fields_ = [
60
+ ('SensorID', c_ushort),
61
+ ('strSensorName', (c_char * 32)),
62
+ ('nColorMode', c_char),
63
+ ('nMaxWidth', c_uint),
64
+ ('nMaxHeight', c_uint),
65
+ ('bMasterGain', c_int),
66
+ ('bRGain', c_int),
67
+ ('bGGain', c_int),
68
+ ('bBGain', c_int),
69
+ ('bGlobShutter', c_int),
70
+ ('wPixelSize', c_ushort),
71
+ ('nUpperLeftBayerPixel', c_char),
72
+ ('Reserved', (c_char * 13)),
73
+ ]
74
+
75
+
76
+ class IS_DEVICE_INFO_HEARTBEAT(Structure):
77
+ _pack_ = 1
78
+ _fields_ = [
79
+ ('reserved_1', (c_ubyte * 24)),
80
+ ('dwRuntimeFirmwareVersion', c_uint),
81
+ ('reserved_2', (c_ubyte * 8)),
82
+ ('wTemperature', c_ushort),
83
+ ('wLinkSpeed_Mb', c_ushort),
84
+ ('reserved_3', (c_ubyte * 6)),
85
+ ('wComportOffset', c_ushort),
86
+ ('reserved', (c_ubyte * 200)),
87
+ ]
88
+
89
+
90
+ class IS_DEVICE_INFO_CONTROL(Structure):
91
+ _pack_ = 1
92
+ _fields_ = [
93
+ ('dwDeviceId', c_uint),
94
+ ('reserved', (c_ubyte * 148)),
95
+ ]
96
+
97
+
98
+ class IS_DEVICE_INFO(Structure):
99
+ _pack_ = 1
100
+ _fields_ = [
101
+ ('infoDevHeartbeat', IS_DEVICE_INFO_HEARTBEAT),
102
+ ('infoDevControl', IS_DEVICE_INFO_CONTROL),
103
+ ('reserved', (c_ubyte * 240)),
104
+ ]
105
+
106
+
107
+ class UC480_CAPTURE_STATUS_INFO(Structure):
108
+ _pack_ = 8
109
+ _fields_ = [
110
+ ('dwCapStatusCnt_Total', c_uint),
111
+ ('reserved', (c_ubyte * 60)),
112
+ ('adwCapStatusCnt_Detail', (c_uint * 256)),
113
+ ]
114
+
115
+
116
+ class _UC480_CAPTURE_STATUS:
117
+ IS_CAP_STATUS_API_NO_DEST_MEM = 0xA2
118
+ IS_CAP_STATUS_API_CONVERSION_FAILED = 0xA3
119
+ IS_CAP_STATUS_API_IMAGE_LOCKED = 0xA5
120
+ IS_CAP_STATUS_DRV_OUT_OF_BUFFERS = 0xB2
121
+ IS_CAP_STATUS_DRV_DEVICE_NOT_READY = 0xB4
122
+ IS_CAP_STATUS_USB_TRANSFER_FAILED = 0xC7
123
+ IS_CAP_STATUS_DEV_MISSED_IMAGES = 0xE5
124
+ IS_CAP_STATUS_DEV_TIMEOUT = 0xD6
125
+ IS_CAP_STATUS_DEV_FRAME_CAPTURE_FAILED = 0xD9
126
+ IS_CAP_STATUS_ETH_BUFFER_OVERRUN = 0xE4
127
+ IS_CAP_STATUS_ETH_MISSED_IMAGES = 0xE5
128
+
129
+
130
+ def UC480_CAMERA_LIST(uci=(UC480_CAMERA_INFO * 1)):
131
+ _uci = uci if isinstance(uci, type) else type(uci)
132
+
133
+ class UC480_CAMERA_LIST(Structure):
134
+ _pack_ = 8
135
+ _fields_ = [
136
+ ('dwCount', c_uint),
137
+ ('uci', _uci),
138
+ ]
139
+
140
+ uc480_camera_list = UC480_CAMERA_LIST()
141
+
142
+ return uc480_camera_list
143
+
144
+
145
+ class CMD:
146
+ IS_SUCCESS = 0
147
+ IS_NO_SUCCESS = -1
148
+ IS_INVALID_CAMERA_HANDLE = 1
149
+ IS_INVALID_HANDLE = 1
150
+ IS_IO_REQUEST_FAILED = 2
151
+ IS_INVALID_MEMORY_POINTER = 49
152
+ IS_INVALID_PARAMETER = 125
153
+
154
+
155
+ class PCLK_CMD:
156
+ IS_PIXELCLOCK_CMD_GET_NUMBER = 1
157
+ IS_PIXELCLOCK_CMD_GET_LIST = 2
158
+ IS_PIXELCLOCK_CMD_GET_RANGE = 3
159
+ IS_PIXELCLOCK_CMD_GET_DEFAULT = 4
160
+ IS_PIXELCLOCK_CMD_GET = 5
161
+ IS_PIXELCLOCK_CMD_SET = 6
162
+
163
+
164
+ class CS_CMD:
165
+ IS_CAPTURE_STATUS_INFO_CMD_RESET = 1
166
+ IS_CAPTURE_STATUS_INFO_CMD_GET = 2
167
+
168
+
169
+ class _AOI:
170
+ IS_AOI_IMAGE_SET_AOI = 0x0001
171
+ IS_AOI_IMAGE_GET_AOI = 0x0002
172
+ IS_AOI_IMAGE_SET_POS = 0x0003
173
+ IS_AOI_IMAGE_GET_POS = 0x0004
174
+ IS_AOI_IMAGE_SET_SIZE = 0x0005
175
+ IS_AOI_IMAGE_GET_SIZE = 0x0006
176
+ IS_AOI_IMAGE_GET_POS_MIN = 0x0007
177
+ IS_AOI_IMAGE_GET_SIZE_MIN = 0x0008
178
+ IS_AOI_IMAGE_GET_POS_MAX = 0x0009
179
+ IS_AOI_IMAGE_GET_SIZE_MAX = 0x0010
180
+ IS_AOI_IMAGE_GET_POS_INC = 0x0011
181
+ IS_AOI_IMAGE_GET_SIZE_INC = 0x0012
182
+ IS_AOI_IMAGE_GET_POS_X_ABS = 0x0013
183
+ IS_AOI_IMAGE_GET_POS_Y_ABS = 0x0014
184
+ IS_AOI_IMAGE_GET_ORIGINAL_AOI = 0x0015
185
+
186
+
187
+ class _EXP:
188
+ IS_EXPOSURE_CMD_GET_CAPS = 1
189
+ IS_EXPOSURE_CMD_GET_EXPOSURE_DEFAULT = 2
190
+ IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MIN = 3
191
+ IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MAX = 4
192
+ IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_INC = 5
193
+ IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE = 6
194
+ IS_EXPOSURE_CMD_GET_EXPOSURE = 7
195
+ IS_EXPOSURE_CMD_GET_FINE_INCREMENT_RANGE_MIN = 8
196
+ IS_EXPOSURE_CMD_GET_FINE_INCREMENT_RANGE_MAX = 9
197
+ IS_EXPOSURE_CMD_GET_FINE_INCREMENT_RANGE_INC = 10
198
+ IS_EXPOSURE_CMD_GET_FINE_INCREMENT_RANGE = 11
199
+ IS_EXPOSURE_CMD_SET_EXPOSURE = 12
200
+ IS_EXPOSURE_CMD_GET_LONG_EXPOSURE_RANGE_MIN = 13
201
+ IS_EXPOSURE_CMD_GET_LONG_EXPOSURE_RANGE_MAX = 14
202
+ IS_EXPOSURE_CMD_GET_LONG_EXPOSURE_RANGE_INC = 15
203
+ IS_EXPOSURE_CMD_GET_LONG_EXPOSURE_RANGE = 16
204
+ IS_EXPOSURE_CMD_GET_LONG_EXPOSURE_ENABLE = 17
205
+ IS_EXPOSURE_CMD_SET_LONG_EXPOSURE_ENABLE = 18
206
+ IS_EXPOSURE_CMD_GET_DUAL_EXPOSURE_RATIO_DEFAULT = 19
207
+ IS_EXPOSURE_CMD_GET_DUAL_EXPOSURE_RATIO_RANGE = 20
208
+ IS_EXPOSURE_CMD_GET_DUAL_EXPOSURE_RATIO = 21
209
+ IS_EXPOSURE_CMD_SET_DUAL_EXPOSURE_RATIO = 22
210
+
211
+
212
+ class IO_FLASH_PARAMS(Structure):
213
+ _pack_ = 8
214
+ _fields_ = [
215
+ ('s32Delay', c_int),
216
+ ('u32Duration', c_uint),
217
+ ]
218
+
219
+
220
+ class FLASH_MODE:
221
+ IO_FLASH_MODE_OFF = 0
222
+ IO_FLASH_MODE_TRIGGER_LO_ACTIVE = 1
223
+ IO_FLASH_MODE_TRIGGER_HI_ACTIVE = 2
224
+ IO_FLASH_MODE_CONSTANT_HIGH = 3
225
+ IO_FLASH_MODE_CONSTANT_LOW = 4
226
+ IO_FLASH_MODE_FREERUN_LO_ACTIVE = 5
227
+ IO_FLASH_MODE_FREERUN_HI_ACTIVE = 6
228
+
229
+ FLASH_MODES = {
230
+ 'Flash Off': IO_FLASH_MODE_OFF,
231
+ 'Flash Trigger Low Active': IO_FLASH_MODE_TRIGGER_LO_ACTIVE,
232
+ 'Flash Trigger High Active': IO_FLASH_MODE_TRIGGER_HI_ACTIVE,
233
+ 'Flash Constant High': IO_FLASH_MODE_CONSTANT_HIGH,
234
+ 'Flash Constant Low': IO_FLASH_MODE_CONSTANT_LOW,
235
+ 'Flash Freerun Low Active': IO_FLASH_MODE_FREERUN_LO_ACTIVE,
236
+ 'Flash Freerun High Active': IO_FLASH_MODE_FREERUN_HI_ACTIVE,
237
+ }
238
+ '''Flash modes supported by Thorlabs cameras.
239
+
240
+ Returns
241
+ -------
242
+ dict[str, int]
243
+ dictionary used for GUI display and control.
244
+ '''
245
+
246
+
247
+ class DEV_FE_CMD:
248
+ IS_DEVICE_FEATURE_CMD_GET_SUPPORTED_FEATURES = 1
249
+ IS_DEVICE_FEATURE_CMD_SET_LINESCAN_MODE = 2
250
+ IS_DEVICE_FEATURE_CMD_GET_LINESCAN_MODE = 3
251
+ IS_DEVICE_FEATURE_CMD_SET_LINESCAN_NUMBER = 4
252
+ IS_DEVICE_FEATURE_CMD_GET_LINESCAN_NUMBER = 5
253
+ IS_DEVICE_FEATURE_CMD_SET_SHUTTER_MODE = 6
254
+ IS_DEVICE_FEATURE_CMD_GET_SHUTTER_MODE = 7
255
+ IS_DEVICE_FEATURE_CMD_SET_PREFER_XS_HS_MODE = 8
256
+ IS_DEVICE_FEATURE_CMD_GET_PREFER_XS_HS_MODE = 9
257
+ IS_DEVICE_FEATURE_CMD_GET_DEFAULT_PREFER_XS_HS_MODE = 10
258
+ IS_DEVICE_FEATURE_CMD_GET_LOG_MODE_DEFAULT = 11
259
+ IS_DEVICE_FEATURE_CMD_GET_LOG_MODE = 12
260
+ IS_DEVICE_FEATURE_CMD_SET_LOG_MODE = 13
261
+ IS_DEVICE_FEATURE_CMD_GET_LOG_MODE_MANUAL_VALUE_DEFAULT = 14
262
+ IS_DEVICE_FEATURE_CMD_GET_LOG_MODE_MANUAL_VALUE_RANGE = 15
263
+ IS_DEVICE_FEATURE_CMD_GET_LOG_MODE_MANUAL_VALUE = 16
264
+ IS_DEVICE_FEATURE_CMD_SET_LOG_MODE_MANUAL_VALUE = 17
265
+ IS_DEVICE_FEATURE_CMD_GET_LOG_MODE_MANUAL_GAIN_DEFAULT = 18
266
+ IS_DEVICE_FEATURE_CMD_GET_LOG_MODE_MANUAL_GAIN_RANGE = 19
267
+ IS_DEVICE_FEATURE_CMD_GET_LOG_MODE_MANUAL_GAIN = 20
268
+ IS_DEVICE_FEATURE_CMD_SET_LOG_MODE_MANUAL_GAIN = 21
269
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_MODE_DEFAULT = 22
270
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_MODE = 23
271
+ IS_DEVICE_FEATURE_CMD_SET_VERTICAL_AOI_MERGE_MODE = 24
272
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_POSITION_DEFAULT = 25
273
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_POSITION_RANGE = 26
274
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_POSITION = 27
275
+ IS_DEVICE_FEATURE_CMD_SET_VERTICAL_AOI_MERGE_POSITION = 28
276
+ IS_DEVICE_FEATURE_CMD_GET_FPN_CORRECTION_MODE_DEFAULT = 29
277
+ IS_DEVICE_FEATURE_CMD_GET_FPN_CORRECTION_MODE = 30
278
+ IS_DEVICE_FEATURE_CMD_SET_FPN_CORRECTION_MODE = 31
279
+ IS_DEVICE_FEATURE_CMD_GET_SENSOR_SOURCE_GAIN_RANGE = 32
280
+ IS_DEVICE_FEATURE_CMD_GET_SENSOR_SOURCE_GAIN_DEFAULT = 33
281
+ IS_DEVICE_FEATURE_CMD_GET_SENSOR_SOURCE_GAIN = 34
282
+ IS_DEVICE_FEATURE_CMD_SET_SENSOR_SOURCE_GAIN = 35
283
+ IS_DEVICE_FEATURE_CMD_GET_BLACK_REFERENCE_MODE_DEFAULT = 36
284
+ IS_DEVICE_FEATURE_CMD_GET_BLACK_REFERENCE_MODE = 37
285
+ IS_DEVICE_FEATURE_CMD_SET_BLACK_REFERENCE_MODE = 38
286
+ IS_DEVICE_FEATURE_CMD_GET_ALLOW_RAW_WITH_LUT = 39
287
+ IS_DEVICE_FEATURE_CMD_SET_ALLOW_RAW_WITH_LUT = 40
288
+ IS_DEVICE_FEATURE_CMD_GET_SUPPORTED_SENSOR_BIT_DEPTHS = 41
289
+ IS_DEVICE_FEATURE_CMD_GET_SENSOR_BIT_DEPTH_DEFAULT = 42
290
+ IS_DEVICE_FEATURE_CMD_GET_SENSOR_BIT_DEPTH = 43
291
+ IS_DEVICE_FEATURE_CMD_SET_SENSOR_BIT_DEPTH = 44
292
+ IS_DEVICE_FEATURE_CMD_GET_TEMPERATURE = 45
293
+ IS_DEVICE_FEATURE_CMD_GET_JPEG_COMPRESSION = 46
294
+ IS_DEVICE_FEATURE_CMD_SET_JPEG_COMPRESSION = 47
295
+ IS_DEVICE_FEATURE_CMD_GET_JPEG_COMPRESSION_DEFAULT = 48
296
+ IS_DEVICE_FEATURE_CMD_GET_JPEG_COMPRESSION_RANGE = 49
297
+ IS_DEVICE_FEATURE_CMD_GET_NOISE_REDUCTION_MODE = 50
298
+ IS_DEVICE_FEATURE_CMD_SET_NOISE_REDUCTION_MODE = 51
299
+ IS_DEVICE_FEATURE_CMD_GET_NOISE_REDUCTION_MODE_DEFAULT = 52
300
+ IS_DEVICE_FEATURE_CMD_GET_TIMESTAMP_CONFIGURATION = 53
301
+ IS_DEVICE_FEATURE_CMD_SET_TIMESTAMP_CONFIGURATION = 54
302
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_HEIGHT_DEFAULT = 55
303
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_HEIGHT_NUMBER = 56
304
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_HEIGHT_LIST = 57
305
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_HEIGHT = 58
306
+ IS_DEVICE_FEATURE_CMD_SET_VERTICAL_AOI_MERGE_HEIGHT = 59
307
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_ADDITIONAL_POSITION_DEF = 60
308
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_ADDITIONAL_POSITION_RANGE = 61
309
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_ADDITIONAL_POSITION = 62
310
+ IS_DEVICE_FEATURE_CMD_SET_VERTICAL_AOI_MERGE_ADDITIONAL_POSITION = 63
311
+ IS_DEVICE_FEATURE_CMD_GET_SENSOR_TEMPERATURE_NUMERICAL_VALUE = 64
312
+ IS_DEVICE_FEATURE_CMD_SET_IMAGE_EFFECT = 65
313
+ IS_DEVICE_FEATURE_CMD_GET_IMAGE_EFFECT = 66
314
+ IS_DEVICE_FEATURE_CMD_GET_IMAGE_EFFECT_DEFAULT = 67
315
+ IS_DEVICE_FEATURE_CMD_GET_EXTENDED_PIXELCLOCK_RANGE_ENABLE_DEFAULT = 68
316
+ IS_DEVICE_FEATURE_CMD_GET_EXTENDED_PIXELCLOCK_RANGE_ENABLE = 69
317
+ IS_DEVICE_FEATURE_CMD_SET_EXTENDED_PIXELCLOCK_RANGE_ENABLE = 70
318
+ IS_DEVICE_FEATURE_CMD_MULTI_INTEGRATION_GET_SCOPE = 71
319
+ IS_DEVICE_FEATURE_CMD_MULTI_INTEGRATION_GET_PARAMS = 72
320
+ IS_DEVICE_FEATURE_CMD_MULTI_INTEGRATION_SET_PARAMS = 73
321
+ IS_DEVICE_FEATURE_CMD_MULTI_INTEGRATION_GET_MODE_DEFAULT = 74
322
+ IS_DEVICE_FEATURE_CMD_MULTI_INTEGRATION_GET_MODE = 75
323
+ IS_DEVICE_FEATURE_CMD_MULTI_INTEGRATION_SET_MODE = 76
324
+ IS_DEVICE_FEATURE_CMD_SET_I2C_TARGET = 77
325
+ IS_DEVICE_FEATURE_CMD_SET_WIDE_DYNAMIC_RANGE_MODE = 78
326
+ IS_DEVICE_FEATURE_CMD_GET_WIDE_DYNAMIC_RANGE_MODE = 79
327
+ IS_DEVICE_FEATURE_CMD_GET_WIDE_DYNAMIC_RANGE_MODE_DEFAULT = 80
328
+ IS_DEVICE_FEATURE_CMD_GET_SUPPORTED_BLACK_REFERENCE_MODES = 81
329
+ IS_DEVICE_FEATURE_CMD_SET_LEVEL_CONTROLLED_TRIGGER_INPUT_MODE = 82
330
+ IS_DEVICE_FEATURE_CMD_GET_LEVEL_CONTROLLED_TRIGGER_INPUT_MODE = 83
331
+ IS_DEVICE_FEATURE_CMD_GET_LEVEL_CONTROLLED_TRIGGER_INPUT_MODE_DEFAULT = 84
332
+ IS_DEVICE_FEATURE_CMD_GET_VERTICAL_AOI_MERGE_MODE_SUPPORTED_LINE_MODES = 85
333
+ IS_DEVICE_FEATURE_CMD_SET_REPEATED_START_CONDITION_I2C = 86
334
+ IS_DEVICE_FEATURE_CMD_GET_REPEATED_START_CONDITION_I2C = 87
335
+ IS_DEVICE_FEATURE_CMD_GET_REPEATED_START_CONDITION_I2C_DEFAULT = 88
336
+ IS_DEVICE_FEATURE_CMD_GET_TEMPERATURE_STATUS = 89
337
+ IS_DEVICE_FEATURE_CMD_GET_MEMORY_MODE_ENABLE = 90
338
+ IS_DEVICE_FEATURE_CMD_SET_MEMORY_MODE_ENABLE = 91
339
+ IS_DEVICE_FEATURE_CMD_GET_MEMORY_MODE_ENABLE_DEFAULT = 92
340
+ IS_DEVICE_FEATURE_CMD_93 = 93
341
+ IS_DEVICE_FEATURE_CMD_94 = 94
342
+ IS_DEVICE_FEATURE_CMD_95 = 95
343
+ IS_DEVICE_FEATURE_CMD_96 = 96
344
+ IS_DEVICE_FEATURE_CMD_GET_SUPPORTED_EXTERNAL_INTERFACES = 97
345
+ IS_DEVICE_FEATURE_CMD_GET_EXTERNAL_INTERFACE = 98
346
+ IS_DEVICE_FEATURE_CMD_SET_EXTERNAL_INTERFACE = 99
347
+ IS_DEVICE_FEATURE_CMD_EXTENDED_AWB_LIMITS_GET = 100
348
+ IS_DEVICE_FEATURE_CMD_EXTENDED_AWB_LIMITS_SET = 101
349
+ IS_DEVICE_FEATURE_CMD_GET_MEMORY_MODE_ENABLE_SUPPORTED = 102
350
+
351
+
352
+ class SENSOR_BIT_DEPTH:
353
+ IS_SENSOR_BIT_DEPTH_AUTO = 0x00000000
354
+ IS_SENSOR_BIT_DEPTH_8_BIT = 0x00000001
355
+ IS_SENSOR_BIT_DEPTH_10_BIT = 0x00000002
356
+ IS_SENSOR_BIT_DEPTH_12_BIT = 0x00000004
357
+
358
+
359
+ class TRIGGER:
360
+ IS_GET_EXTERNALTRIGGER = 0x8000
361
+ IS_SET_TRIGGER_MASK = 0x0100
362
+ IS_SET_TRIGGER_CONTINUOUS = 0x1000
363
+ IS_SET_TRIGGER_OFF = 0x0000
364
+ IS_SET_TRIGGER_HI_LO = IS_SET_TRIGGER_CONTINUOUS | 0x0001
365
+ IS_SET_TRIGGER_LO_HI = IS_SET_TRIGGER_CONTINUOUS | 0x0002
366
+ IS_SET_TRIGGER_SOFTWARE = IS_SET_TRIGGER_CONTINUOUS | 0x0008
367
+ IS_SET_TRIGGER_HI_LO_SYNC = 0x0010
368
+ IS_SET_TRIGGER_LO_HI_SYNC = 0x0020
369
+ IS_SET_TRIGGER_PRE_HI_LO = IS_SET_TRIGGER_CONTINUOUS | 0x0040
370
+ IS_SET_TRIGGER_PRE_LO_HI = IS_SET_TRIGGER_CONTINUOUS | 0x0080
371
+
372
+ TRIGGER_MODES = {
373
+ 'Trigger Off': IS_SET_TRIGGER_OFF,
374
+ 'Software Trigger': IS_SET_TRIGGER_SOFTWARE,
375
+ 'Falling edge external trigger': IS_SET_TRIGGER_HI_LO,
376
+ 'Rising edge external trigger': IS_SET_TRIGGER_LO_HI,
377
+ }
378
+ '''Tigger modes supported by Thorlabs cameras.
379
+
380
+ Returns
381
+ -------
382
+ dict[str, int]
383
+ dictionary used for GUI display and control.
384
+ '''
385
+
386
+
387
+ class IO_CMD:
388
+ IS_IO_CMD_GPIOS_GET_SUPPORTED = 1
389
+ IS_IO_CMD_GPIOS_GET_SUPPORTED_INPUTS = 2
390
+ IS_IO_CMD_GPIOS_GET_SUPPORTED_OUTPUTS = 3
391
+ IS_IO_CMD_GPIOS_GET_DIRECTION = 4
392
+ IS_IO_CMD_GPIOS_SET_DIRECTION = 5
393
+ IS_IO_CMD_GPIOS_GET_STATE = 6
394
+ IS_IO_CMD_GPIOS_SET_STATE = 7
395
+ IS_IO_CMD_LED_GET_STATE = 8
396
+ IS_IO_CMD_LED_SET_STATE = 9
397
+ IS_IO_CMD_LED_TOGGLE_STATE = 10
398
+ IS_IO_CMD_FLASH_GET_GLOBAL_PARAMS = 11
399
+ IS_IO_CMD_FLASH_APPLY_GLOBAL_PARAMS = 12
400
+ IS_IO_CMD_FLASH_GET_SUPPORTED_GPIOS = 13
401
+ IS_IO_CMD_FLASH_GET_PARAMS_MIN = 14
402
+ IS_IO_CMD_FLASH_GET_PARAMS_MAX = 15
403
+ IS_IO_CMD_FLASH_GET_PARAMS_INC = 16
404
+ IS_IO_CMD_FLASH_GET_PARAMS = 17
405
+ IS_IO_CMD_FLASH_SET_PARAMS = 18
406
+ IS_IO_CMD_FLASH_GET_MODE = 19
407
+ IS_IO_CMD_FLASH_SET_MODE = 20
408
+ IS_IO_CMD_PWM_GET_SUPPORTED_GPIOS = 21
409
+ IS_IO_CMD_PWM_GET_PARAMS_MIN = 22
410
+ IS_IO_CMD_PWM_GET_PARAMS_MAX = 23
411
+ IS_IO_CMD_PWM_GET_PARAMS_INC = 24
412
+ IS_IO_CMD_PWM_GET_PARAMS = 25
413
+ IS_IO_CMD_PWM_SET_PARAMS = 26
414
+ IS_IO_CMD_PWM_GET_MODE = 27
415
+ IS_IO_CMD_PWM_SET_MODE = 28
416
+ IS_IO_CMD_GPIOS_GET_CONFIGURATION = 29
417
+ IS_IO_CMD_GPIOS_SET_CONFIGURATION = 30
418
+ IS_IO_CMD_FLASH_GET_GPIO_PARAMS_MIN = 31
419
+ IS_IO_CMD_FLASH_SET_GPIO_PARAMS = 32
420
+ IS_IO_CMD_FLASH_GET_AUTO_FREERUN_DEFAULT = 33
421
+ IS_IO_CMD_FLASH_GET_AUTO_FREERUN = 34
422
+ IS_IO_CMD_FLASH_SET_AUTO_FREERUN = 35
423
+
424
+
425
+ class ColorMode:
426
+ IS_COLORMODE_INVALID = 0
427
+ IS_COLORMODE_MONOCHROME = 1
428
+ IS_COLORMODE_BAYER = 2
429
+ IS_COLORMODE_CBYCRY = 4
430
+ IS_COLORMODE_JPEG = 8
431
+
432
+
433
+ ColorModeStr = {
434
+ ColorMode.IS_COLORMODE_INVALID: 'IS_COLORMODE_INVALID',
435
+ ColorMode.IS_COLORMODE_MONOCHROME: 'IS_COLORMODE_MONOCHROME',
436
+ ColorMode.IS_COLORMODE_BAYER: 'IS_COLORMODE_BAYER',
437
+ ColorMode.IS_COLORMODE_CBYCRY: 'IS_COLORMODE_CBYCRY',
438
+ ColorMode.IS_COLORMODE_JPEG: 'IS_COLORMODE_JPEG',
439
+ }
440
+
441
+
442
+ class _ColorModes:
443
+ IS_CM_SENSOR_RAW8 = 11
444
+ IS_CM_SENSOR_RAW10 = 33
445
+ IS_CM_SENSOR_RAW12 = 27
446
+ IS_CM_SENSOR_RAW16 = 29
447
+ IS_CM_MONO8 = 6
448
+ IS_CM_MONO10 = 34
449
+ IS_CM_MONO12 = 26
450
+ IS_CM_MONO16 = 28
451
+
452
+ IS_CM_ORDER_BGR = 0x0000
453
+ IS_CM_ORDER_RGB = 0x0080
454
+ IS_CM_ORDER_MASK = 0x0080
455
+ IS_CM_FORMAT_PLANAR = 0x2000
456
+ IS_CM_BGR5_PACKED = 3 | IS_CM_ORDER_BGR
457
+ IS_CM_BGR565_PACKED = 2 | IS_CM_ORDER_BGR
458
+ IS_CM_RGB8_PACKED = 1 | IS_CM_ORDER_RGB
459
+ IS_CM_BGR8_PACKED = 1 | IS_CM_ORDER_BGR
460
+ IS_CM_RGBA8_PACKED = 0 | IS_CM_ORDER_RGB
461
+ IS_CM_BGRA8_PACKED = 0 | IS_CM_ORDER_BGR
462
+ IS_CM_RGBY8_PACKED = 24 | IS_CM_ORDER_RGB
463
+ IS_CM_BGRY8_PACKED = 24 | IS_CM_ORDER_BGR
464
+ IS_CM_RGB10_PACKED = 25 | IS_CM_ORDER_RGB
465
+ IS_CM_BGR10_PACKED = 25 | IS_CM_ORDER_BGR
466
+ IS_CM_RGB10_UNPACKED = 35 | IS_CM_ORDER_RGB
467
+ IS_CM_BGR10_UNPACKED = 35 | IS_CM_ORDER_BGR
468
+ IS_CM_RGB12_UNPACKED = 30 | IS_CM_ORDER_RGB
469
+ IS_CM_BGR12_UNPACKED = 30 | IS_CM_ORDER_BGR
470
+ IS_CM_RGBA12_UNPACKED = 31 | IS_CM_ORDER_RGB
471
+ IS_CM_BGRA12_UNPACKED = 31 | IS_CM_ORDER_BGR
472
+ IS_CM_UYVY_PACKED = 12
473
+ IS_CM_UYVY_MONO_PACKED = 13
474
+ IS_CM_UYVY_BAYER_PACKED = 14
475
+ IS_CM_CBYCRY_PACKED = 23
476
+ IS_CM_RGB8_PLANAR = 1 | IS_CM_ORDER_RGB | IS_CM_FORMAT_PLANAR
477
+
478
+
479
+ formats_ = {
480
+ _ColorModes.IS_CM_SENSOR_RAW8: 8,
481
+ _ColorModes.IS_CM_SENSOR_RAW10: 16,
482
+ _ColorModes.IS_CM_SENSOR_RAW12: 16,
483
+ _ColorModes.IS_CM_SENSOR_RAW16: 16,
484
+ _ColorModes.IS_CM_MONO8: 8,
485
+ _ColorModes.IS_CM_MONO10: 16,
486
+ _ColorModes.IS_CM_MONO12: 16,
487
+ _ColorModes.IS_CM_MONO16: 16,
488
+ _ColorModes.IS_CM_RGB8_PLANAR: 24,
489
+ _ColorModes.IS_CM_RGB8_PACKED: 24,
490
+ _ColorModes.IS_CM_RGBA8_PACKED: 32,
491
+ _ColorModes.IS_CM_RGBY8_PACKED: 32,
492
+ _ColorModes.IS_CM_RGB10_PACKED: 32,
493
+ _ColorModes.IS_CM_RGB10_UNPACKED: 48,
494
+ _ColorModes.IS_CM_RGB12_UNPACKED: 48,
495
+ _ColorModes.IS_CM_RGBA12_UNPACKED: 64,
496
+ _ColorModes.IS_CM_BGR5_PACKED: 16,
497
+ _ColorModes.IS_CM_BGR565_PACKED: 16,
498
+ _ColorModes.IS_CM_BGR8_PACKED: 24,
499
+ _ColorModes.IS_CM_BGRA8_PACKED: 32,
500
+ _ColorModes.IS_CM_BGRY8_PACKED: 32,
501
+ _ColorModes.IS_CM_BGR10_PACKED: 32,
502
+ _ColorModes.IS_CM_BGR10_UNPACKED: 48,
503
+ _ColorModes.IS_CM_BGR12_UNPACKED: 48,
504
+ _ColorModes.IS_CM_BGRA12_UNPACKED: 64,
505
+ _ColorModes.IS_CM_UYVY_PACKED: 16,
506
+ _ColorModes.IS_CM_UYVY_MONO_PACKED: 16,
507
+ _ColorModes.IS_CM_UYVY_BAYER_PACKED: 16,
508
+ _ColorModes.IS_CM_CBYCRY_PACKED: 16,
509
+ }
510
+
511
+ formats_strs = {
512
+ _ColorModes.IS_CM_SENSOR_RAW8: 'IS_CM_SENSOR_RAW8',
513
+ _ColorModes.IS_CM_SENSOR_RAW10: 'IS_CM_SENSOR_RAW10',
514
+ _ColorModes.IS_CM_SENSOR_RAW12: 'IS_CM_SENSOR_RAW12',
515
+ _ColorModes.IS_CM_SENSOR_RAW16: 'IS_CM_SENSOR_RAW16',
516
+ _ColorModes.IS_CM_MONO8: 'IS_CM_MONO8',
517
+ _ColorModes.IS_CM_MONO10: 'IS_CM_MONO10',
518
+ _ColorModes.IS_CM_MONO12: 'IS_CM_MONO12',
519
+ _ColorModes.IS_CM_MONO16: 'IS_CM_MONO16',
520
+ _ColorModes.IS_CM_RGB8_PLANAR: 'IS_CM_RGB8_PLANAR',
521
+ _ColorModes.IS_CM_RGB8_PACKED: 'IS_CM_RGB8_PACKED',
522
+ _ColorModes.IS_CM_RGBA8_PACKED: 'IS_CM_RGB8_PACKED',
523
+ _ColorModes.IS_CM_RGBY8_PACKED: 'IS_CM_RGBY8_PACKED',
524
+ _ColorModes.IS_CM_RGB10_PACKED: 'IS_CM_RGB10_PACKED',
525
+ _ColorModes.IS_CM_RGB10_UNPACKED: 'IS_CM_RGB10_UNPACKED',
526
+ _ColorModes.IS_CM_RGB12_UNPACKED: 'IS_CM_RGB12_UNPACKED',
527
+ _ColorModes.IS_CM_RGBA12_UNPACKED: 'IS_CM_RGBA12_UNPACKED',
528
+ _ColorModes.IS_CM_BGR5_PACKED: 'IS_CM_BGR5_PACKED',
529
+ _ColorModes.IS_CM_BGR565_PACKED: 'IS_CM_BGR565_PACKED',
530
+ _ColorModes.IS_CM_BGR8_PACKED: 'IS_CM_BGR8_PACKED',
531
+ _ColorModes.IS_CM_BGRA8_PACKED: 'IS_CM_BGRA8_PACKED',
532
+ _ColorModes.IS_CM_BGRY8_PACKED: 'IS_CM_BGRY8_PACKED',
533
+ _ColorModes.IS_CM_BGR10_PACKED: 'IS_CM_BGR10_PACKED',
534
+ _ColorModes.IS_CM_BGR10_UNPACKED: 'IS_CM_BGR10_UNPACKED',
535
+ _ColorModes.IS_CM_BGR12_UNPACKED: 'IS_CM_BGR12_UNPACKED',
536
+ _ColorModes.IS_CM_BGRA12_UNPACKED: 'IS_CM_BGRA12_UNPACKED',
537
+ _ColorModes.IS_CM_UYVY_PACKED: 'IS_CM_UYVY_PACKED',
538
+ _ColorModes.IS_CM_UYVY_MONO_PACKED: 'IS_CM_UYVY_MONO_PACKED',
539
+ _ColorModes.IS_CM_UYVY_BAYER_PACKED: 'IS_CM_UYVY_BAYER_PACKED',
540
+ _ColorModes.IS_CM_CBYCRY_PACKED: 'IS_CM_CBYCRY_PACKED',
541
+ }
542
+
543
+
544
+ def get_data(image_mem, x, y, bits, pitch, copy):
545
+ data = None
546
+ if copy:
547
+ mem = create_string_buffer(y * pitch)
548
+ memmove(mem, image_mem, y * pitch)
549
+ data = np.frombuffer(mem, dtype=np.uint8) if np else mem
550
+ else:
551
+ data = (
552
+ np.ctypeslib.as_array(cast(image_mem, POINTER(c_ubyte)), (y * pitch,))
553
+ if np
554
+ else image_mem
555
+ )
556
+
557
+ return data
558
+
559
+
560
+ IS_DEVICE_INFO_CMD_GET_DEVICE_INFO = 0x02010001
561
+ IS_SET_DM_DIB = 1
562
+ IS_SET_DM_DIRECT3D = 4
563
+ IS_SET_DM_OPENGL = 8
564
+ IS_WAIT = 0x0001
565
+ IS_DONT_WAIT = 0x0000
566
+ IS_FORCE_VIDEO_STOP = 0x4000
567
+ IS_FORCE_VIDEO_START = 0x4000
568
+ IS_USE_NEXT_MEM = 0x8000
569
+ IS_TIMED_OUT = 122
570
+ IS_CAPTURE_STATUS = 0x0003
571
+ IS_TRIGGER_MISSED = 20
572
+ IS_GET_STATUS = 0x8000
573
+ IS_GET_COLOR_MODE = 0x8000
574
+
575
+
576
+ class thorlabs_camera(miCamera):
577
+ uc480_file = (
578
+ 'C:\\Program Files\\Thorlabs\\Scientific' + ' Imaging\\ThorCam\\uc480_64.dll'
579
+ )
580
+
581
+ def __init__(self, hCam=0):
582
+ super().__init__(hCam)
583
+ if os.path.isfile(thorlabs_camera.uc480_file):
584
+ self.bit_depth = 8
585
+ self.supported_bit_depth = c_uint(0)
586
+ self.bytes_per_pixel = int(self.bit_depth / 8)
587
+ self.color_mode = c_int(0)
588
+ self.minROI = IS_SIZE_2D()
589
+ self.rectROI = IS_RECT()
590
+ self.set_rectROI = IS_RECT()
591
+ self.cam = None
592
+ self.hCam = c_int(hCam)
593
+ self.meminfo = None
594
+ self.exposure_current = c_double(0.05)
595
+ self.exposure_range = (c_double * 3)()
596
+ self.roi_pos = None
597
+ self.min_framerate = c_double(0)
598
+ self.max_framerate = c_double(0)
599
+ self.increment_framerate = c_double(0)
600
+ self.current_framerate = c_double(0)
601
+ self.pixel_clock = c_uint(0)
602
+ self.pixel_clock_def = c_uint(0)
603
+ self.pixel_clock_count = c_uint(0)
604
+ self.pixel_clock_list = None
605
+
606
+ self.MemInfo = []
607
+ self.pitch = c_int()
608
+ self.current_buffer = c_void_p()
609
+ self.current_id = c_int()
610
+
611
+ self.flash_mode = c_uint(FLASH_MODE.IO_FLASH_MODE_OFF)
612
+ self.flash_min = IO_FLASH_PARAMS()
613
+ self.flash_max = IO_FLASH_PARAMS()
614
+ self.flash_inc = IO_FLASH_PARAMS()
615
+ self.flash_cur = IO_FLASH_PARAMS()
616
+
617
+ self.sInfo = SENSORINFO()
618
+ self.cInfo = BOARDINFO()
619
+ self.dInfo = IS_DEVICE_INFO()
620
+ self.dInfo_not_supported = False
621
+
622
+ self.CaptureStatusInfo = UC480_CAPTURE_STATUS_INFO()
623
+
624
+ self.acquisition = False
625
+ self.capture_video = False
626
+ self.memory_allocated = False
627
+ self.trigger_mode = None
628
+ self.temperature = -127
629
+ self.uc480 = windll.LoadLibrary(thorlabs_camera.uc480_file)
630
+ else:
631
+ raise Exception('Please install ThorCam drivers.')
632
+
633
+ @staticmethod
634
+ def get_camera_list(output=False):
635
+ '''Gets the list of available IDS cameras
636
+
637
+ Parameters
638
+ ----------
639
+ output : bool, optional
640
+ print out camera list, by default False
641
+
642
+ Returns
643
+ -------
644
+ dict[str, object]
645
+ dictionary containing
646
+ {Camera ID, Device ID, Sensor ID, Status, InUse, Model, Serial}
647
+ '''
648
+ uc480 = windll.LoadLibrary(thorlabs_camera.uc480_file)
649
+ cam_list = []
650
+ cam_count = c_int(0)
651
+ nRet = uc480.is_GetNumberOfCameras(byref(cam_count))
652
+ if nRet == CMD.IS_SUCCESS and cam_count.value > 0:
653
+ pucl = UC480_CAMERA_LIST(UC480_CAMERA_INFO * cam_count.value)
654
+ pucl.dwCount = cam_count.value
655
+ if uc480.is_GetCameraList(byref(pucl)) == CMD.IS_SUCCESS:
656
+ for index in range(cam_count.value):
657
+ cam_list.append(
658
+ {
659
+ 'Camera ID': pucl.uci[index].dwCameraID,
660
+ 'Device ID': pucl.uci[index].dwDeviceID,
661
+ 'Sensor ID': pucl.uci[index].dwSensorID,
662
+ 'Status': pucl.uci[index].dwStatus,
663
+ 'InUse': pucl.uci[index].dwInUse,
664
+ 'Model': pucl.uci[index].Model.decode('utf-8'),
665
+ 'Serial': pucl.uci[index].SerNo.decode('utf-8'),
666
+ 'Driver': 'Thorlabs DCx UC480',
667
+ }
668
+ )
669
+ if output:
670
+ print(cam_list)
671
+ return cam_list
672
+
673
+ def get_coded_info(self):
674
+ '''Reads out the data hard-coded in the non-volatile camera memory
675
+ and writes it to the data structure that cInfo points to
676
+ '''
677
+ nRet = self.uc480.is_GetCameraInfo(self.hCam, byref(self.cInfo))
678
+ if nRet != CMD.IS_SUCCESS:
679
+ print('is_GetCameraInfo ERROR')
680
+
681
+ def get_device_info(self):
682
+ '''Gets the device info, used to get the sensor temp.'''
683
+ if not self.dInfo_not_supported:
684
+ nRet = self.uc480.is_DeviceInfo(
685
+ self.hCam,
686
+ IS_DEVICE_INFO_CMD_GET_DEVICE_INFO,
687
+ byref(self.dInfo),
688
+ sizeof(IS_DEVICE_INFO),
689
+ )
690
+
691
+ if nRet != CMD.IS_SUCCESS:
692
+ self.dInfo_not_supported = True
693
+ print('is_DeviceInfo ERROR', nRet)
694
+
695
+ return nRet
696
+ else:
697
+ return 125
698
+
699
+ def get_temperature(self):
700
+ '''Reads out the sensor temperature value
701
+
702
+ Returns
703
+ -------
704
+ float
705
+ camera sensor temperature in C.
706
+ '''
707
+ nRet = self.get_device_info()
708
+ self.temperature = -127
709
+ if nRet == CMD.IS_SUCCESS:
710
+ self.temperature = (
711
+ (self.dInfo.infoDevHeartbeat.wTemperature >> 4) & 127
712
+ ) * 1.0 + ((self.dInfo.infoDevHeartbeat.wTemperature & 15) / 10.0)
713
+ return self.temperature
714
+
715
+ def get_sensor_info(self):
716
+ '''You can query additional information about
717
+ the sensor type used in the camera
718
+ '''
719
+ nRet = self.uc480.is_GetSensorInfo(self.hCam, byref(self.sInfo))
720
+ if nRet != CMD.IS_SUCCESS:
721
+ print('is_GetSensorInfo ERROR')
722
+
723
+ def resetToDefault(self):
724
+ '''Resets all parameters to the camera-specific defaults
725
+ as specified by the driver.
726
+
727
+ By default, the camera uses full resolution, a medium speed
728
+ and color level gain values adapted to daylight exposure.
729
+ '''
730
+ nRet = self.uc480.is_ResetToDefault(self.hCam)
731
+ if nRet != CMD.IS_SUCCESS:
732
+ print('is_ResetToDefault ERROR')
733
+
734
+ def initialize(self):
735
+ is_InitCamera = self.uc480.is_InitCamera
736
+ is_InitCamera.argtypes = [POINTER(c_int)]
737
+ i = is_InitCamera(byref(self.hCam))
738
+
739
+ if i == 0:
740
+ print('Camera initialized successfully.')
741
+
742
+ self.get_coded_info()
743
+ self.get_sensor_info()
744
+ self.resetToDefault()
745
+ self.set_display_mode()
746
+
747
+ self.set_color_mode()
748
+ # self.is_GetColorDepth()
749
+
750
+ self.get_roi()
751
+ self.get_min_roi()
752
+
753
+ self.get_pixel_clock_info(False)
754
+ self.set_pixel_clock(self.pixel_clock_def.value)
755
+ self.get_framerate_range(False)
756
+ self.get_exposure_range(False)
757
+ self.get_flash_range(False)
758
+
759
+ self.name = (
760
+ self.sInfo.strSensorName.decode('utf-8')
761
+ + '_'
762
+ + self.cInfo.SerNo.decode('utf-8')
763
+ )
764
+ self.name = str.replace(self.name, '-', '_')
765
+
766
+ self.print_status()
767
+
768
+ return CMD.IS_SUCCESS
769
+ else:
770
+ print('Camera initialization failed with error code ' + str(i))
771
+ return i
772
+
773
+ # Prints out some information about the camera and the sensor
774
+ def populate_status(self):
775
+ self.status['Camera'] = {
776
+ 'Model': self.sInfo.strSensorName.decode('utf-8'),
777
+ 'Serial no.:\t': self.cInfo.SerNo.decode('utf-8'),
778
+ 'Pixel Clock [MHz]': self.pixel_clock.value,
779
+ 'Clock Count ': str(self.pixel_clock_count.value),
780
+ }
781
+
782
+ self.status['Temperature'] = {'Value': self.temperature, 'Unit': 'Celsius'}
783
+
784
+ self.status['Exposure'] = {
785
+ 'Value': self.exposure_current.value,
786
+ 'Unit': 'ms',
787
+ 'Range': [self.exposure_range[0].value, self.exposure_range[1].value],
788
+ 'Increment': self.exposure_range[2].value,
789
+ }
790
+
791
+ self.status['Framerate'] = {
792
+ 'Value': self.current_framerate,
793
+ 'Unit': 'Hz',
794
+ 'Range': [self.min_framerate.value, self.max_framerate.value],
795
+ 'Increment': self.increment_framerate.value,
796
+ }
797
+
798
+ nCmode = int.from_bytes(self.sInfo.nColorMode, byteorder='big')
799
+
800
+ self.status['Image Format'] = {
801
+ 'Color Mode': ColorModeStr[nCmode],
802
+ 'Pixel Format': formats_strs[self.color_mode],
803
+ 'Bit Depth': self.bit_depth,
804
+ 'Bytes per Pixel': self.bytes_per_pixel,
805
+ }
806
+
807
+ self.status['Image Size'] = {
808
+ 'Width': self.width,
809
+ 'Height': self.height,
810
+ }
811
+
812
+ def refresh_info(self, output=False):
813
+ """Refreshes the camera's pixel clock,
814
+ framerate, exposure and flash ranges.
815
+
816
+ Parameters
817
+ ----------
818
+ output : bool, optional
819
+ True to printout errors, by default False
820
+ """
821
+ if output:
822
+ print(self.name)
823
+ print()
824
+ self.get_pixel_clock_info(output)
825
+ self.get_framerate_range(output)
826
+ self.get_exposure_range(output)
827
+ self.get_exposure(output)
828
+ self.get_flash_range(output)
829
+
830
+ def close(self):
831
+ if self.hCam is not None:
832
+ self.stop_live_capture()
833
+ i = self.uc480.is_ExitCamera(self.hCam)
834
+ if i == 0:
835
+ print('Camera closed successfully.')
836
+ else:
837
+ print('Closing the camera failed with error code ' + str(i))
838
+ else:
839
+ return
840
+
841
+ def stop_live_capture(self):
842
+ self.uc480.is_StopLiveVideo(self.hCam, 1)
843
+
844
+ def set_color_mode(self):
845
+ '''Set the right color mode, by camera default.'''
846
+ # self.color_mode = self.uc480.is_SetColorMode(
847
+ # self.hCam, IS_GET_COLOR_MODE)
848
+ nCmode = int.from_bytes(self.sInfo.nColorMode, byteorder='big')
849
+ nRet = self.uc480.is_DeviceFeature(
850
+ self.hCam,
851
+ DEV_FE_CMD.IS_DEVICE_FEATURE_CMD_GET_SUPPORTED_SENSOR_BIT_DEPTHS,
852
+ byref(self.supported_bit_depth),
853
+ sizeof(self.supported_bit_depth),
854
+ )
855
+ print('nRet', nRet)
856
+ if nCmode == ColorMode.IS_COLORMODE_BAYER:
857
+ # setup the color depth to the current windows setting
858
+ self.uc480.is_GetColorDepth(
859
+ self.hCam, byref(self.bit_depth), byref(self.color_mode)
860
+ )
861
+ self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
862
+ print(
863
+ ColorModeStr[nCmode],
864
+ ': ',
865
+ )
866
+ print('\tcolor_mode: \t\t', formats_strs[self.color_mode])
867
+ print('\tbit_depth: \t\t', self.bit_depth)
868
+ print('\tbytes_per_pixel: \t\t', self.bytes_per_pixel)
869
+ print()
870
+
871
+ elif nCmode == ColorMode.IS_COLORMODE_CBYCRY:
872
+ # for color camera models use RGB32 mode
873
+ self.color_mode = _ColorModes.IS_CM_BGRA8_PACKED
874
+ self.bit_depth = 32
875
+ self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
876
+ print(
877
+ ColorModeStr[nCmode],
878
+ ': ',
879
+ )
880
+ print('\tcolor_mode: \t\t', formats_strs[self.color_mode])
881
+ print('\tbit_depth: \t\t', self.bit_depth)
882
+ print('\tbytes_per_pixel: \t\t', self.bytes_per_pixel)
883
+ print()
884
+
885
+ elif nCmode == ColorMode.IS_COLORMODE_MONOCHROME:
886
+ # for mono camera models that uses CM_MONO12 mode
887
+ print('Sbit', self.supported_bit_depth)
888
+ if nRet == CMD.IS_SUCCESS:
889
+ if (
890
+ self.supported_bit_depth
891
+ and SENSOR_BIT_DEPTH.IS_SENSOR_BIT_DEPTH_12_BIT
892
+ ) != 0:
893
+ self.color_mode = _ColorModes.IS_CM_MONO12
894
+ self.bit_depth = 12
895
+ self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
896
+ elif (
897
+ self.supported_bit_depth
898
+ and SENSOR_BIT_DEPTH.IS_SENSOR_BIT_DEPTH_10_BIT
899
+ ) != 0:
900
+ self.color_mode = _ColorModes.IS_CM_MONO10
901
+ self.bit_depth = 10
902
+ self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
903
+ elif (
904
+ self.supported_bit_depth
905
+ and SENSOR_BIT_DEPTH.IS_SENSOR_BIT_DEPTH_8_BIT
906
+ ) != 0:
907
+ self.color_mode = _ColorModes.IS_CM_MONO8
908
+ self.bit_depth = 8
909
+ self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
910
+ else:
911
+ self.color_mode = _ColorModes.IS_CM_MONO8
912
+ self.bit_depth = 8
913
+ self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
914
+ print(
915
+ ColorModeStr[nCmode],
916
+ ': ',
917
+ )
918
+ print('\tcolor_mode: \t\t', formats_strs[self.color_mode])
919
+ print('\tbit_depth: \t\t', self.bit_depth)
920
+ print('\tbytes_per_pixel: \t\t', self.bytes_per_pixel)
921
+ print()
922
+
923
+ else:
924
+ # for monochrome camera models use Y8 mode
925
+ self.color_mode = _ColorModes.IS_CM_MONO8
926
+ self.bit_depth = 8
927
+ self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
928
+ print(
929
+ 'Else: ',
930
+ )
931
+ print('\tcolor_mode: \t\t', formats_strs[self.color_mode])
932
+ print('\tbit_depth: \t\t', self.bit_depth)
933
+ print('\tbytes_per_pixel: \t\t', self.bytes_per_pixel)
934
+
935
+ nRet = self.uc480.is_SetColorMode(self.hCam, self.color_mode)
936
+
937
+ def get_color_depth(self):
938
+ is_GetColorDepth = self.uc480.is_GetColorDepth
939
+ is_GetColorDepth.argtypes = [c_int, POINTER(c_int), POINTER(c_int)]
940
+ is_GetColorDepth(self.hCam, byref(self.bit_depth), byref(self.color_mode))
941
+
942
+ self.bytes_per_pixel = int(self.bit_depth.value / 8)
943
+
944
+ def set_display_mode(self, mode=IS_SET_DM_DIB):
945
+ '''Captures an image in system memory (RAM).
946
+
947
+ Using is_RenderBitmap(), you can define the image display (default).
948
+
949
+ Parameters
950
+ ----------
951
+ mode : [type], optional
952
+ Capture mode, by default IS_SET_DM_DIB
953
+ captures an image in system memory (RAM).
954
+
955
+ Returns
956
+ -------
957
+ int
958
+ is_SetDisplayMode return code
959
+ '''
960
+ nRet = self.uc480.is_SetDisplayMode(self.hCam, mode)
961
+ return nRet
962
+
963
+ def get_pixel_clock(self, output=True):
964
+ '''Gets the current pixel clock speed.
965
+
966
+ Parameters
967
+ ----------
968
+ output : bool, optional
969
+ print out to terminal, by default True
970
+
971
+ Returns
972
+ -------
973
+ int
974
+ pixel clock speed in MHz.
975
+ '''
976
+ is_PixelClock = self.uc480.is_PixelClock
977
+ is_PixelClock.argtypes = [c_int, c_uint, POINTER(c_uint), c_uint]
978
+ nRet = is_PixelClock(
979
+ self.hCam,
980
+ PCLK_CMD.IS_PIXELCLOCK_CMD_GET,
981
+ byref(self.pixel_clock),
982
+ sizeof(self.pixel_clock),
983
+ )
984
+
985
+ if nRet != 0:
986
+ print('is_PixelClock ERROR')
987
+ elif output:
988
+ print('Pixel Clock %d MHz' % self.pixel_clock.value)
989
+ return self.pixel_clock.value
990
+
991
+ def set_pixel_clock(self, value):
992
+ """Sets the camera's pixel clock speed.
993
+
994
+ Parameters
995
+ ----------
996
+ value : uint
997
+ The supported clock speed to set.
998
+
999
+ Returns
1000
+ -------
1001
+ int
1002
+ is_PixelClock return code.
1003
+ """
1004
+ set = c_uint(value)
1005
+ is_PixelClock = self.uc480.is_PixelClock
1006
+ is_PixelClock.argtypes = [c_int, c_uint, POINTER(c_uint), c_uint]
1007
+ nRet = is_PixelClock(
1008
+ self.hCam, PCLK_CMD.IS_PIXELCLOCK_CMD_SET, byref(set), sizeof(set)
1009
+ )
1010
+
1011
+ if nRet != CMD.IS_SUCCESS:
1012
+ print('is_PixelClock ERROR')
1013
+
1014
+ return nRet
1015
+
1016
+ def get_pixel_clock_info(self, output=False):
1017
+ self.get_pixel_clock()
1018
+
1019
+ is_PixelClock = self.uc480.is_PixelClock
1020
+ is_PixelClock.argtypes = [c_int, c_uint, POINTER(c_uint), c_uint]
1021
+ nRet = is_PixelClock(
1022
+ self.hCam,
1023
+ PCLK_CMD.IS_PIXELCLOCK_CMD_GET_DEFAULT,
1024
+ byref(self.pixel_clock_def),
1025
+ sizeof(self.pixel_clock_def),
1026
+ )
1027
+
1028
+ nRet = is_PixelClock(
1029
+ self.hCam,
1030
+ PCLK_CMD.IS_PIXELCLOCK_CMD_GET_NUMBER,
1031
+ byref(self.pixel_clock_count),
1032
+ sizeof(self.pixel_clock_count),
1033
+ )
1034
+
1035
+ if nRet != 0:
1036
+ print('is_PixelClock Count ERROR')
1037
+ else:
1038
+ if output:
1039
+ print('Count ' + str(self.pixel_clock_count.value))
1040
+
1041
+ self.pixel_clock_list = (c_uint * self.pixel_clock_count.value)()
1042
+
1043
+ nRet = is_PixelClock(
1044
+ self.hCam,
1045
+ PCLK_CMD.IS_PIXELCLOCK_CMD_GET_LIST,
1046
+ self.pixel_clock_list,
1047
+ self.pixel_clock_count.value * sizeof(c_uint),
1048
+ )
1049
+
1050
+ if nRet != 0:
1051
+ print('is_PixelClock List ERROR')
1052
+ elif output:
1053
+ for clk in self.pixel_clock_list:
1054
+ print('List ' + str(clk))
1055
+ print()
1056
+
1057
+ def get_roi(self):
1058
+ '''Can be used to get the size and position
1059
+ of an "area of interest" (ROI) within an image.
1060
+
1061
+ For ROI rectangle check IDS_Camera.rectROI
1062
+
1063
+ Returns
1064
+ -------
1065
+ int
1066
+ is_AOI return code.
1067
+ '''
1068
+ nRet = self.uc480.is_AOI(
1069
+ self.hCam,
1070
+ _AOI.IS_AOI_IMAGE_GET_AOI,
1071
+ byref(self.rectROI),
1072
+ sizeof(self.rectROI),
1073
+ )
1074
+
1075
+ if nRet != CMD.IS_SUCCESS:
1076
+ print('is_AOI GET ERROR')
1077
+
1078
+ self.width = self.rectROI.s32Width
1079
+ self.height = self.rectROI.s32Height
1080
+ return nRet
1081
+
1082
+ def get_min_roi(self):
1083
+ '''Can be used to get the size of the minimum
1084
+ "area of interest" (ROI).
1085
+
1086
+ Returns
1087
+ -------
1088
+ int
1089
+ is_AOI return code.
1090
+ '''
1091
+ nRet = self.uc480.is_AOI(
1092
+ self.hCam,
1093
+ _AOI.IS_AOI_IMAGE_GET_SIZE_MIN,
1094
+ byref(self.minROI),
1095
+ sizeof(self.minROI),
1096
+ )
1097
+ if nRet != CMD.IS_SUCCESS:
1098
+ print('is_AOI GET MIN SIZE ERROR')
1099
+ return nRet
1100
+
1101
+ def set_roi(self, x, y, width, height):
1102
+ '''Sets the size and position of an
1103
+ "area of interest"(ROI) within an image.
1104
+
1105
+ Parameters
1106
+ ----------
1107
+ x : int
1108
+ ROI x position.
1109
+ y : int
1110
+ ROI y position.
1111
+ width : int
1112
+ ROI width.
1113
+ height : int
1114
+ ROI height.
1115
+
1116
+ Returns
1117
+ -------
1118
+ int
1119
+ is_AOI return code.
1120
+ '''
1121
+ self.set_rectROI.s32X = x
1122
+ self.set_rectROI.s32Y = y
1123
+ self.set_rectROI.s32Width = max(self.minROI.s32Width, width)
1124
+ self.set_rectROI.s32Height = max(self.minROI.s32Height, height)
1125
+
1126
+ nRet = self.uc480.is_AOI(
1127
+ self.hCam,
1128
+ _AOI.IS_AOI_IMAGE_SET_AOI,
1129
+ byref(self.set_rectROI),
1130
+ sizeof(self.set_rectROI),
1131
+ )
1132
+
1133
+ if nRet != CMD.IS_SUCCESS:
1134
+ print('is_AOI SET ERROR')
1135
+
1136
+ self.width = self.set_rectROI.s32Width
1137
+ self.height = self.set_rectROI.s32Height
1138
+
1139
+ return nRet
1140
+
1141
+ def reset_roi(self):
1142
+ '''Resets the ROI.
1143
+
1144
+ Returns
1145
+ -------
1146
+ int
1147
+ is_AOI return code.
1148
+ '''
1149
+ nRet = self.uc480.is_AOI(
1150
+ self.hCam,
1151
+ _AOI.IS_AOI_IMAGE_SET_AOI,
1152
+ byref(self.rectROI),
1153
+ sizeof(self.rectROI),
1154
+ )
1155
+
1156
+ if nRet != CMD.IS_SUCCESS:
1157
+ print('is_AOI RESET ERROR')
1158
+
1159
+ self.width = self.rectROI.s32Width
1160
+ self.height = self.rectROI.s32Height
1161
+
1162
+ return nRet
1163
+
1164
+ # Set exposure
1165
+ def set_exposure(self, value):
1166
+ is_Exposure = self.uc480.is_Exposure
1167
+ is_Exposure.argtypes = [c_int, c_uint, POINTER(c_double), c_uint]
1168
+ nRet = is_Exposure(
1169
+ self.hCam,
1170
+ _EXP.IS_EXPOSURE_CMD_SET_EXPOSURE,
1171
+ c_double(max(min(value, self.exposure_range[1]), self.exposure_range[0])),
1172
+ sizeof(c_double),
1173
+ )
1174
+ if nRet != CMD.IS_SUCCESS:
1175
+ print('is_Exposure Set ERROR')
1176
+ else:
1177
+ print('Exposure set to ' + str(self.get_exposure(False)))
1178
+ print()
1179
+ return nRet
1180
+
1181
+ def get_exposure_range(self, output=True):
1182
+ '''Gets exposure range
1183
+
1184
+ Parameters
1185
+ ----------
1186
+ output : bool, optional
1187
+ [description], by default True
1188
+ '''
1189
+ nRet = self.uc480.is_Exposure(
1190
+ self.hCam,
1191
+ _EXP.IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE,
1192
+ self.exposure_range,
1193
+ sizeof(self.exposure_range),
1194
+ )
1195
+ if nRet != CMD.IS_SUCCESS:
1196
+ print('is_Exposure Range ERROR')
1197
+ elif output:
1198
+ print('Exposure')
1199
+ print('Min ' + str(self.exposure_range[0]))
1200
+ print('Max ' + str(self.exposure_range[1]))
1201
+ print('Inc ' + str(self.exposure_range[2]))
1202
+ print()
1203
+
1204
+ # Get exposure
1205
+ def get_exposure(self, output=True):
1206
+ nRet = self.uc480.is_Exposure(
1207
+ self.hCam,
1208
+ _EXP.IS_EXPOSURE_CMD_GET_EXPOSURE,
1209
+ byref(self.exposure_current),
1210
+ sizeof(self.exposure_current),
1211
+ )
1212
+ if nRet != CMD.IS_SUCCESS:
1213
+ print('is_Exposure Current ERROR')
1214
+ elif output:
1215
+ print('Current Exposure ' + str(self.exposure_current.value))
1216
+ print()
1217
+ return self.exposure_current.value
1218
+
1219
+ # Get framerate range
1220
+ def get_framerate_range(self, output=True):
1221
+ nRet = self.uc480.is_GetFrameTimeRange(
1222
+ self.hCam,
1223
+ byref(self.min_framerate),
1224
+ byref(self.max_framerate),
1225
+ byref(self.increment_framerate),
1226
+ )
1227
+ if nRet != CMD.IS_SUCCESS:
1228
+ print('is_GetFrameTimeRange ERROR')
1229
+ else:
1230
+ temp = self.max_framerate.value
1231
+ self.max_framerate.value = 1 / self.min_framerate.value
1232
+ self.min_framerate.value = 1 / temp
1233
+ if output:
1234
+ print('FrameRate')
1235
+ print('Min ' + str(self.min_framerate.value))
1236
+ print('Max ' + str(self.max_framerate.value))
1237
+ print()
1238
+ return np.array([self.min_framerate.value, self.max_framerate.value])
1239
+
1240
+ # Get current framerate
1241
+ def get_framerate(self, output=True):
1242
+ nRet = self.uc480.is_GetFramesPerSecond(
1243
+ self.hCam, byref(self.current_framerate)
1244
+ )
1245
+ if nRet != CMD.IS_SUCCESS:
1246
+ print('is_GetFramesPerSecond ERROR')
1247
+ elif output:
1248
+ print('Current FrameRate ' + str(self.current_framerate.value))
1249
+ print()
1250
+ return self.current_framerate.value
1251
+
1252
+ # Set current framerate
1253
+ def set_framerate(self, value):
1254
+ nRet = self.uc480.is_SetFrameRate(
1255
+ self.hCam,
1256
+ c_double(
1257
+ max(min(value, self.max_framerate.value), self.min_framerate.value)
1258
+ ),
1259
+ byref(self.current_framerate),
1260
+ )
1261
+ if nRet != CMD.IS_SUCCESS:
1262
+ print('is_SetFrameRate ERROR')
1263
+ else:
1264
+ print('FrameRate set to ' + str(self.current_framerate.value))
1265
+ print()
1266
+ return nRet
1267
+
1268
+ # get trigger mode
1269
+ def get_trigger_mode(self):
1270
+ nRet = self.uc480.is_SetExternalTrigger(
1271
+ self.hCam, TRIGGER.IS_GET_EXTERNALTRIGGER
1272
+ )
1273
+ if nRet == TRIGGER.IS_SET_TRIGGER_OFF:
1274
+ print('Trigger Off')
1275
+ elif nRet == TRIGGER.IS_SET_TRIGGER_SOFTWARE:
1276
+ print('Software Trigger')
1277
+ elif nRet == TRIGGER.IS_SET_TRIGGER_HI_LO:
1278
+ print('Falling edge external trigger')
1279
+ elif nRet == TRIGGER.IS_SET_TRIGGER_LO_HI:
1280
+ print('Rising edge external trigger')
1281
+ else:
1282
+ print('NA')
1283
+ self.trigger_mode = nRet
1284
+ return nRet
1285
+
1286
+ def set_trigger_mode(self, mode):
1287
+ return self.uc480.is_SetExternalTrigger(self.hCam, mode)
1288
+
1289
+ # Get flash output info
1290
+ def get_flash_range(self, output=True):
1291
+ nRet = self.uc480.is_IO(
1292
+ self.hCam,
1293
+ IO_CMD.IS_IO_CMD_FLASH_GET_PARAMS_MIN,
1294
+ byref(self.flash_min),
1295
+ sizeof(self.flash_min),
1296
+ )
1297
+ if nRet != CMD.IS_SUCCESS:
1298
+ print('is_IO Flash Min ERROR')
1299
+ elif output:
1300
+ print('Flash Output')
1301
+ print('Min Delay (us) ' + str(self.flash_min.s32Delay))
1302
+ print('Min Duration (us) ' + str(self.flash_min.u32Duration))
1303
+ print()
1304
+
1305
+ nRet = self.uc480.is_IO(
1306
+ self.hCam,
1307
+ IO_CMD.IS_IO_CMD_FLASH_GET_PARAMS_MAX,
1308
+ byref(self.flash_max),
1309
+ sizeof(self.flash_max),
1310
+ )
1311
+ if nRet != CMD.IS_SUCCESS:
1312
+ print('is_IO Flash Max ERROR')
1313
+ elif output:
1314
+ print('Max Delay (us) ' + str(self.flash_max.s32Delay))
1315
+ print('Max Duration (us) ' + str(self.flash_max.u32Duration))
1316
+ print()
1317
+
1318
+ nRet = self.uc480.is_IO(
1319
+ self.hCam,
1320
+ IO_CMD.IS_IO_CMD_FLASH_GET_PARAMS_INC,
1321
+ byref(self.flash_inc),
1322
+ sizeof(self.flash_inc),
1323
+ )
1324
+ if nRet != CMD.IS_SUCCESS:
1325
+ print('is_IO Flash Inc. ERROR')
1326
+ elif output:
1327
+ print('Inc. Delay (us) ' + str(self.flash_inc.s32Delay))
1328
+ print('Inc. Duration (us) ' + str(self.flash_inc.u32Duration))
1329
+ print()
1330
+
1331
+ self.get_flash_params(output)
1332
+
1333
+ def get_flash_params(self, output=True):
1334
+ nRet = self.uc480.is_IO(
1335
+ self.hCam,
1336
+ IO_CMD.IS_IO_CMD_FLASH_GET_PARAMS,
1337
+ byref(self.flash_cur),
1338
+ sizeof(self.flash_cur),
1339
+ )
1340
+ if nRet != CMD.IS_SUCCESS:
1341
+ print('is_IO Flash Current ERROR')
1342
+ elif output:
1343
+ print('Current Delay (us) ' + str(self.flash_cur.s32Delay))
1344
+ print('Current Duration (us) ' + str(self.flash_cur.u32Duration))
1345
+ print()
1346
+
1347
+ # Set current flash parameters
1348
+ def set_flash_params(self, delay, duration):
1349
+ params = IO_FLASH_PARAMS()
1350
+ delay = int(delay)
1351
+ duration = c_uint(duration)
1352
+ if duration != 0:
1353
+ params.u32Duration = max(
1354
+ min(duration, self.flash_max.u32Duration), self.flash_min.u32Duration
1355
+ )
1356
+ else:
1357
+ params.u32Duration = duration
1358
+ params.s32Delay.value = max(
1359
+ min(delay, self.flash_max.s32Delay), self.flash_min.s32Delay
1360
+ )
1361
+ nRet = self.uc480.is_IO(
1362
+ self.hCam, IO_CMD.IS_IO_CMD_FLASH_SET_PARAMS, params, sizeof(params)
1363
+ )
1364
+ if nRet != CMD.IS_SUCCESS:
1365
+ print('set_flash_params ERROR', nRet)
1366
+ else:
1367
+ self.get_flash_params()
1368
+ return nRet
1369
+
1370
+ # Set current flash mode
1371
+ def set_flash_mode(self, mode):
1372
+ mode = c_uint(mode)
1373
+ nRet = self.uc480.is_IO(
1374
+ self.hCam, IO_CMD.IS_IO_CMD_FLASH_SET_MODE, byref(mode), sizeof(mode)
1375
+ )
1376
+ if nRet != CMD.IS_SUCCESS:
1377
+ print('is_IO Set Flash Mode ERROR', nRet)
1378
+ return nRet
1379
+
1380
+ # Get current flash mode
1381
+ def get_flash_mode(self, output=False):
1382
+ nRet = self.uc480.is_IO(
1383
+ self.hCam,
1384
+ IO_CMD.IS_IO_CMD_FLASH_GET_MODE,
1385
+ byref(self.flash_mode),
1386
+ sizeof(self.flash_mode),
1387
+ )
1388
+ if nRet != CMD.IS_SUCCESS:
1389
+ print('is_IO Get Flash Mode ERROR')
1390
+ else:
1391
+ print(
1392
+ list(FLASH_MODE.FLASH_MODES.keys())[
1393
+ list(FLASH_MODE.FLASH_MODES.values()).index(self.flash_mode.value)
1394
+ ]
1395
+ )
1396
+
1397
+ def allocate_memory(self, buffers: int = 100):
1398
+ if len(self.MemInfo) > 0:
1399
+ self.free_memory()
1400
+
1401
+ for x in range(buffers):
1402
+ self.MemInfo.append([c_void_p(), c_int(0)])
1403
+ ret = self.uc480.is_AllocImageMem(
1404
+ self.hCam,
1405
+ c_int(self.width),
1406
+ c_int(self.height),
1407
+ self.bit_depth,
1408
+ byref(self.MemInfo[x][0]),
1409
+ byref(self.MemInfo[x][1]),
1410
+ )
1411
+ ret = self.uc480.is_AddToSequence(
1412
+ self.hCam, self.MemInfo[x][0], self.MemInfo[x][1]
1413
+ )
1414
+
1415
+ ret = self.uc480.is_InitImageQueue(self.hCam, c_int(0))
1416
+
1417
+ def unlock_buffer(self):
1418
+ return self.uc480.is_UnlockSeqBuf(
1419
+ self.hCam, self.current_id, self.current_buffer
1420
+ )
1421
+
1422
+ # Activates the camera's live video mode (free run mode)
1423
+ def start_live_capture(self):
1424
+ nRet = self.uc480.is_CaptureVideo(self.hCam, IS_DONT_WAIT)
1425
+ if nRet != CMD.IS_SUCCESS:
1426
+ print('is_CaptureVideo ERROR')
1427
+ else:
1428
+ self.capture_video = True
1429
+ return nRet
1430
+
1431
+ # Stops the camera's live video mode (free run mode)
1432
+ def stop_live_capture(self):
1433
+ nRet = self.uc480.is_StopLiveVideo(self.hCam, IS_FORCE_VIDEO_STOP)
1434
+ if nRet != CMD.IS_SUCCESS:
1435
+ print('is_StopLiveVideo ERROR')
1436
+ else:
1437
+ self.capture_video = False
1438
+ return nRet
1439
+
1440
+ def get_pitch(self):
1441
+ x = c_int()
1442
+ y = c_int()
1443
+ bits = c_int()
1444
+
1445
+ pc_mem = c_void_p()
1446
+ pid = c_int()
1447
+ self.uc480.is_GetActiveImageMem(self.hCam, byref(pc_mem), byref(pid))
1448
+ self.uc480.is_InquireImageMem(
1449
+ self.hCam, pc_mem, pid, byref(x), byref(y), byref(bits), byref(self.pitch)
1450
+ )
1451
+
1452
+ return self.pitch.value
1453
+
1454
+ # Releases an image memory that was allocated using is_AllocImageMem()
1455
+ # and removes it from the driver management
1456
+ def free_memory(self):
1457
+ nRet = 0
1458
+ for x in range(len(self.MemInfo)):
1459
+ nRet += self.uc480.is_FreeImageMem(
1460
+ self.hCam, byref(self.MemInfo[x][0]), self.MemInfo[x][1]
1461
+ )
1462
+ self.MemInfo.clear()
1463
+ self.memory_allocated = False
1464
+ return nRet
1465
+
1466
+ def wait_for_next_image(self, wait=0, log=True):
1467
+ nret = self.uc480.is_WaitForNextImage(
1468
+ self.hCam, wait, byref(self.current_buffer), byref(self.current_id)
1469
+ )
1470
+ if nret == CMD.IS_SUCCESS:
1471
+ if log:
1472
+ logging.debug(f'is_WaitForNextImage, IS_SUCCESS: {nret}')
1473
+ elif nret == IS_TIMED_OUT:
1474
+ if log:
1475
+ logging.debug(f'is_WaitForNextImage, IS_TIMED_OUT: {nret}')
1476
+ elif nret == IS_CAPTURE_STATUS:
1477
+ if log:
1478
+ logging.debug(f'is_WaitForNextImage, IS_CAPTURE_STATUS: {nret}')
1479
+ self.CaptureStatusInfo = UC480_CAPTURE_STATUS_INFO()
1480
+ nRet = self.uc480.is_CaptureStatus(
1481
+ self.hCam,
1482
+ CS_CMD.IS_CAPTURE_STATUS_INFO_CMD_GET,
1483
+ self.CaptureStatusInfo,
1484
+ sizeof(self.CaptureStatusInfo),
1485
+ )
1486
+ if nRet == CMD.IS_SUCCESS:
1487
+ self.uc480.is_CaptureStatus(
1488
+ self.hCam, CS_CMD.IS_CAPTURE_STATUS_INFO_CMD_RESET, None, 0
1489
+ )
1490
+ return nret
1491
+
1492
+ def get_data(self):
1493
+ # In order to display the image in an OpenCV window we need to...
1494
+ # ...extract the data of our image memory
1495
+ return get_data(
1496
+ self.current_buffer,
1497
+ self.width,
1498
+ self.height,
1499
+ self.bit_depth,
1500
+ self.pitch.value,
1501
+ copy=False,
1502
+ )
1503
+
1504
+ # Disables the hCam camera handle and releases the data structures
1505
+ # and memory areas taken up by the camera
1506
+ def dispose(self):
1507
+ nRet = self.uc480.is_ExitCamera(self.hCam)
1508
+ return nRet