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,1023 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from ctypes import *
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from microEye.hardware.cams.micam import miCamera
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
from pyueye import ueye
|
|
10
|
+
except Exception:
|
|
11
|
+
ueye = None
|
|
12
|
+
|
|
13
|
+
formats_ = {
|
|
14
|
+
ueye.IS_CM_SENSOR_RAW8: 8,
|
|
15
|
+
ueye.IS_CM_SENSOR_RAW10: 16,
|
|
16
|
+
ueye.IS_CM_SENSOR_RAW12: 16,
|
|
17
|
+
ueye.IS_CM_SENSOR_RAW16: 16,
|
|
18
|
+
ueye.IS_CM_MONO8: 8,
|
|
19
|
+
ueye.IS_CM_MONO10: 16,
|
|
20
|
+
ueye.IS_CM_MONO12: 16,
|
|
21
|
+
ueye.IS_CM_MONO16: 16,
|
|
22
|
+
ueye.IS_CM_RGB8_PLANAR: 24,
|
|
23
|
+
ueye.IS_CM_RGB8_PACKED: 24,
|
|
24
|
+
ueye.IS_CM_RGBA8_PACKED: 32,
|
|
25
|
+
ueye.IS_CM_RGBY8_PACKED: 32,
|
|
26
|
+
ueye.IS_CM_RGB10_PACKED: 32,
|
|
27
|
+
ueye.IS_CM_RGB10_UNPACKED: 48,
|
|
28
|
+
ueye.IS_CM_RGB12_UNPACKED: 48,
|
|
29
|
+
ueye.IS_CM_RGBA12_UNPACKED: 64,
|
|
30
|
+
ueye.IS_CM_BGR5_PACKED: 16,
|
|
31
|
+
ueye.IS_CM_BGR565_PACKED: 16,
|
|
32
|
+
ueye.IS_CM_BGR8_PACKED: 24,
|
|
33
|
+
ueye.IS_CM_BGRA8_PACKED: 32,
|
|
34
|
+
ueye.IS_CM_BGRY8_PACKED: 32,
|
|
35
|
+
ueye.IS_CM_BGR10_PACKED: 32,
|
|
36
|
+
ueye.IS_CM_BGR10_UNPACKED: 48,
|
|
37
|
+
ueye.IS_CM_BGR12_UNPACKED: 48,
|
|
38
|
+
ueye.IS_CM_BGRA12_UNPACKED: 64,
|
|
39
|
+
ueye.IS_CM_UYVY_PACKED: 16,
|
|
40
|
+
ueye.IS_CM_UYVY_MONO_PACKED: 16,
|
|
41
|
+
ueye.IS_CM_UYVY_BAYER_PACKED: 16,
|
|
42
|
+
ueye.IS_CM_CBYCRY_PACKED: 16,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
formats_strs = {
|
|
46
|
+
ueye.IS_CM_SENSOR_RAW8: 'IS_CM_SENSOR_RAW8',
|
|
47
|
+
ueye.IS_CM_SENSOR_RAW10: 'IS_CM_SENSOR_RAW10',
|
|
48
|
+
ueye.IS_CM_SENSOR_RAW12: 'IS_CM_SENSOR_RAW12',
|
|
49
|
+
ueye.IS_CM_SENSOR_RAW16: 'IS_CM_SENSOR_RAW16',
|
|
50
|
+
ueye.IS_CM_MONO8: 'IS_CM_MONO8',
|
|
51
|
+
ueye.IS_CM_MONO10: 'IS_CM_MONO10',
|
|
52
|
+
ueye.IS_CM_MONO12: 'IS_CM_MONO12',
|
|
53
|
+
ueye.IS_CM_MONO16: 'IS_CM_MONO16',
|
|
54
|
+
ueye.IS_CM_RGB8_PLANAR: 'IS_CM_RGB8_PLANAR',
|
|
55
|
+
ueye.IS_CM_RGB8_PACKED: 'IS_CM_RGB8_PACKED',
|
|
56
|
+
ueye.IS_CM_RGBA8_PACKED: 'IS_CM_RGB8_PACKED',
|
|
57
|
+
ueye.IS_CM_RGBY8_PACKED: 'IS_CM_RGBY8_PACKED',
|
|
58
|
+
ueye.IS_CM_RGB10_PACKED: 'IS_CM_RGB10_PACKED',
|
|
59
|
+
ueye.IS_CM_RGB10_UNPACKED: 'IS_CM_RGB10_UNPACKED',
|
|
60
|
+
ueye.IS_CM_RGB12_UNPACKED: 'IS_CM_RGB12_UNPACKED',
|
|
61
|
+
ueye.IS_CM_RGBA12_UNPACKED: 'IS_CM_RGBA12_UNPACKED',
|
|
62
|
+
ueye.IS_CM_BGR5_PACKED: 'IS_CM_BGR5_PACKED',
|
|
63
|
+
ueye.IS_CM_BGR565_PACKED: 'IS_CM_BGR565_PACKED',
|
|
64
|
+
ueye.IS_CM_BGR8_PACKED: 'IS_CM_BGR8_PACKED',
|
|
65
|
+
ueye.IS_CM_BGRA8_PACKED: 'IS_CM_BGRA8_PACKED',
|
|
66
|
+
ueye.IS_CM_BGRY8_PACKED: 'IS_CM_BGRY8_PACKED',
|
|
67
|
+
ueye.IS_CM_BGR10_PACKED: 'IS_CM_BGR10_PACKED',
|
|
68
|
+
ueye.IS_CM_BGR10_UNPACKED: 'IS_CM_BGR10_UNPACKED',
|
|
69
|
+
ueye.IS_CM_BGR12_UNPACKED: 'IS_CM_BGR12_UNPACKED',
|
|
70
|
+
ueye.IS_CM_BGRA12_UNPACKED: 'IS_CM_BGRA12_UNPACKED',
|
|
71
|
+
ueye.IS_CM_UYVY_PACKED: 'IS_CM_UYVY_PACKED',
|
|
72
|
+
ueye.IS_CM_UYVY_MONO_PACKED: 'IS_CM_UYVY_MONO_PACKED',
|
|
73
|
+
ueye.IS_CM_UYVY_BAYER_PACKED: 'IS_CM_UYVY_BAYER_PACKED',
|
|
74
|
+
ueye.IS_CM_CBYCRY_PACKED: 'IS_CM_CBYCRY_PACKED',
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
color_modes_ = {
|
|
78
|
+
ueye.IS_COLORMODE_INVALID: 'IS_COLORMODE_INVALID',
|
|
79
|
+
ueye.IS_COLORMODE_MONOCHROME: 'IS_COLORMODE_MONOCHROME',
|
|
80
|
+
ueye.IS_COLORMODE_BAYER: 'IS_COLORMODE_BAYER',
|
|
81
|
+
ueye.IS_COLORMODE_CBYCRY: 'IS_COLORMODE_CBYCRY',
|
|
82
|
+
ueye.IS_COLORMODE_JPEG: 'IS_COLORMODE_JPEG',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class IDS_Camera(miCamera):
|
|
87
|
+
'''A class to handle an IDS uEye camera.'''
|
|
88
|
+
|
|
89
|
+
TRIGGER_MODES = {
|
|
90
|
+
'Trigger Off': ueye.IS_SET_TRIGGER_OFF,
|
|
91
|
+
'Software Trigger': ueye.IS_SET_TRIGGER_SOFTWARE,
|
|
92
|
+
'Falling edge external trigger': ueye.IS_SET_TRIGGER_HI_LO,
|
|
93
|
+
'Rising edge external trigger': ueye.IS_SET_TRIGGER_LO_HI,
|
|
94
|
+
}
|
|
95
|
+
'''Tigger modes supported by IDS uEye cameras.
|
|
96
|
+
|
|
97
|
+
Returns
|
|
98
|
+
-------
|
|
99
|
+
dict[str, int]
|
|
100
|
+
dictionary used for GUI display and control.
|
|
101
|
+
'''
|
|
102
|
+
|
|
103
|
+
FLASH_MODES = {
|
|
104
|
+
'Flash Off': ueye.IO_FLASH_MODE_OFF,
|
|
105
|
+
'Flash Trigger Low Active': ueye.IO_FLASH_MODE_TRIGGER_LO_ACTIVE,
|
|
106
|
+
'Flash Trigger High Active': ueye.IO_FLASH_MODE_TRIGGER_HI_ACTIVE,
|
|
107
|
+
'Flash Constant High': ueye.IO_FLASH_MODE_CONSTANT_HIGH,
|
|
108
|
+
'Flash Constant Low': ueye.IO_FLASH_MODE_CONSTANT_LOW,
|
|
109
|
+
'Flash Freerun Low Active': ueye.IO_FLASH_MODE_FREERUN_LO_ACTIVE,
|
|
110
|
+
'Flash Freerun High Active': ueye.IO_FLASH_MODE_FREERUN_HI_ACTIVE,
|
|
111
|
+
}
|
|
112
|
+
'''Flash modes supported by IDS uEye cameras.
|
|
113
|
+
|
|
114
|
+
Returns
|
|
115
|
+
-------
|
|
116
|
+
dict[str, int]
|
|
117
|
+
dictionary used for GUI display and control.
|
|
118
|
+
'''
|
|
119
|
+
|
|
120
|
+
def __init__(self, Cam_ID=0):
|
|
121
|
+
'''Initializes a new IDS_Camera with the specified Cam_ID.
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
Cam_ID : int, optional
|
|
127
|
+
camera ID, by default 0
|
|
128
|
+
|
|
129
|
+
0: first available camera
|
|
130
|
+
|
|
131
|
+
1-254: The camera with the specified camera ID
|
|
132
|
+
'''
|
|
133
|
+
# Variables
|
|
134
|
+
super().__init__(Cam_ID)
|
|
135
|
+
# 0: first available camera;
|
|
136
|
+
# 1-254: The camera with the specified camera ID
|
|
137
|
+
self.hCam = ueye.HIDS(Cam_ID)
|
|
138
|
+
self.sInfo = ueye.SENSORINFO()
|
|
139
|
+
self.cInfo = ueye.CAMINFO()
|
|
140
|
+
self.dInfo = ueye.IS_DEVICE_INFO()
|
|
141
|
+
self.rectROI = ueye.IS_RECT()
|
|
142
|
+
self.set_rectROI = ueye.IS_RECT()
|
|
143
|
+
self.minROI = ueye.IS_SIZE_2D()
|
|
144
|
+
|
|
145
|
+
self.pitch = ueye.INT()
|
|
146
|
+
self.MemInfo = []
|
|
147
|
+
self.current_buffer = ueye.c_mem_p()
|
|
148
|
+
self.current_id = ueye.int()
|
|
149
|
+
self.pcImageMemory = ueye.c_mem_p()
|
|
150
|
+
self.MemID = ueye.int()
|
|
151
|
+
|
|
152
|
+
self.bit_depth = ueye.INT(24)
|
|
153
|
+
# 3: channels for color mode(RGB);
|
|
154
|
+
# take 1 channel for monochrome
|
|
155
|
+
self.channels = 1
|
|
156
|
+
self.color_mode = ueye.INT()
|
|
157
|
+
self.bit_depth = ueye.UINT(0)
|
|
158
|
+
self.supported_bit_depth = ueye.UINT(0)
|
|
159
|
+
self.bytes_per_pixel = int(self.bit_depth / 8)
|
|
160
|
+
|
|
161
|
+
self.pixel_clock = ueye.c_uint(0)
|
|
162
|
+
self.pixel_clock_default = ueye.c_uint()
|
|
163
|
+
self.pixel_clock_list = (ueye.c_uint * 5)()
|
|
164
|
+
self.pixel_clock_range = (ueye.c_uint * 3)()
|
|
165
|
+
self.pixel_clock_count = ueye.c_uint()
|
|
166
|
+
|
|
167
|
+
self.min_framerate = ueye.c_double(0)
|
|
168
|
+
self.max_framerate = ueye.c_double(0)
|
|
169
|
+
self.increment_framerate = ueye.c_double(0)
|
|
170
|
+
self.current_framerate = ueye.c_double(0)
|
|
171
|
+
self.exposure_range = (ueye.c_double * 3)()
|
|
172
|
+
self.exposure_current = ueye.c_double(0)
|
|
173
|
+
|
|
174
|
+
self.flash_mode = ueye.c_uint(ueye.IO_FLASH_MODE_OFF)
|
|
175
|
+
self.flash_min = ueye.IO_FLASH_PARAMS()
|
|
176
|
+
self.flash_max = ueye.IO_FLASH_PARAMS()
|
|
177
|
+
self.flash_inc = ueye.IO_FLASH_PARAMS()
|
|
178
|
+
self.flash_cur = ueye.IO_FLASH_PARAMS()
|
|
179
|
+
|
|
180
|
+
self.CaptureStatusInfo = ueye.UEYE_CAPTURE_STATUS_INFO()
|
|
181
|
+
|
|
182
|
+
self.acquisition = False
|
|
183
|
+
self.capture_video = False
|
|
184
|
+
self.memory_allocated = False
|
|
185
|
+
self.trigger_mode = None
|
|
186
|
+
self.temperature = -127
|
|
187
|
+
|
|
188
|
+
def initialize(self):
|
|
189
|
+
'''Starts the driver and establishes the connection to the camera'''
|
|
190
|
+
nRet = ueye.is_InitCamera(self.hCam, None)
|
|
191
|
+
if nRet != ueye.IS_SUCCESS:
|
|
192
|
+
print('is_InitCamera ' + str(self.Cam_ID) + ' ERROR')
|
|
193
|
+
|
|
194
|
+
self.get_coded_info()
|
|
195
|
+
self.get_sensor_info()
|
|
196
|
+
self.reset_to_default()
|
|
197
|
+
self.set_display_mode()
|
|
198
|
+
self.set_color_mode()
|
|
199
|
+
self.get_roi()
|
|
200
|
+
|
|
201
|
+
self.name = (
|
|
202
|
+
self.sInfo.strSensorName.decode('utf-8')
|
|
203
|
+
+ '_'
|
|
204
|
+
+ self.cInfo.SerNo.decode('utf-8')
|
|
205
|
+
)
|
|
206
|
+
self.name = str.replace(self.name, '-', '_')
|
|
207
|
+
|
|
208
|
+
self.refresh_info(False)
|
|
209
|
+
|
|
210
|
+
self.print_status()
|
|
211
|
+
|
|
212
|
+
# Prints out some information about the camera and the sensor
|
|
213
|
+
def populate_status(self):
|
|
214
|
+
self.status['Camera'] = {
|
|
215
|
+
'Model': self.sInfo.strSensorName.decode('utf-8'),
|
|
216
|
+
'Serial no.:\t': self.cInfo.SerNo.decode('utf-8'),
|
|
217
|
+
'Pixel Clock [MHz]': self.pixel_clock.value,
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
self.status['Temperature'] = {'Value': self.temperature, 'Unit': 'Celsius'}
|
|
221
|
+
|
|
222
|
+
self.status['Exposure'] = {
|
|
223
|
+
'Value': self.exposure_current.value,
|
|
224
|
+
'Unit': 'ms',
|
|
225
|
+
'Range': [self.exposure_range[0].value, self.exposure_range[1].value],
|
|
226
|
+
'Increment': self.exposure_range[2].value,
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
self.status['Framerate'] = {
|
|
230
|
+
'Value': self.current_framerate,
|
|
231
|
+
'Unit': 'Hz',
|
|
232
|
+
'Range': [self.min_framerate.value, self.max_framerate.value],
|
|
233
|
+
'Increment': self.increment_framerate.value,
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
nCmode = int.from_bytes(self.sInfo.nColorMode.value, byteorder='big')
|
|
237
|
+
|
|
238
|
+
self.status['Image Format'] = {
|
|
239
|
+
'Color Mode': color_modes_[nCmode],
|
|
240
|
+
'Pixel Format': formats_strs[self.color_mode],
|
|
241
|
+
'Bit Depth': self.bit_depth,
|
|
242
|
+
'Bytes per Pixel': self.bytes_per_pixel,
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
self.status['Image Size'] = {
|
|
246
|
+
'Width': self.width.value,
|
|
247
|
+
'Height': self.height.value,
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
def refresh_info(self, output=False):
|
|
251
|
+
"""Refreshes the camera's pixel clock,
|
|
252
|
+
framerate, exposure and flash ranges.
|
|
253
|
+
|
|
254
|
+
Parameters
|
|
255
|
+
----------
|
|
256
|
+
output : bool, optional
|
|
257
|
+
True to printout errors, by default False
|
|
258
|
+
"""
|
|
259
|
+
if output:
|
|
260
|
+
print(self.name)
|
|
261
|
+
print()
|
|
262
|
+
self.get_pixel_clock_info(output)
|
|
263
|
+
self.get_framerate_range(output)
|
|
264
|
+
self.get_exposure_range(output)
|
|
265
|
+
self.get_exposure(output)
|
|
266
|
+
self.get_flash_range(output)
|
|
267
|
+
|
|
268
|
+
@staticmethod
|
|
269
|
+
def get_camera_list(output=False):
|
|
270
|
+
'''Gets the list of available IDS cameras
|
|
271
|
+
|
|
272
|
+
Parameters
|
|
273
|
+
----------
|
|
274
|
+
output : bool, optional
|
|
275
|
+
print out camera list, by default False
|
|
276
|
+
|
|
277
|
+
Returns
|
|
278
|
+
-------
|
|
279
|
+
dict[str, object]
|
|
280
|
+
dictionary containing
|
|
281
|
+
{Camera ID, Device ID, Sensor ID, Status, InUse, Model, Serial}
|
|
282
|
+
'''
|
|
283
|
+
cam_list = []
|
|
284
|
+
cam_count = ueye.c_int(0)
|
|
285
|
+
nRet = ueye.is_GetNumberOfCameras(cam_count)
|
|
286
|
+
if nRet == ueye.IS_SUCCESS and cam_count > 0:
|
|
287
|
+
pucl = ueye.UEYE_CAMERA_LIST(ueye.UEYE_CAMERA_INFO * cam_count.value)
|
|
288
|
+
pucl.dwCount = cam_count.value
|
|
289
|
+
if ueye.is_GetCameraList(pucl) == ueye.IS_SUCCESS:
|
|
290
|
+
for index in range(cam_count.value):
|
|
291
|
+
cam_list.append(
|
|
292
|
+
{
|
|
293
|
+
'Camera ID': pucl.uci[index].dwCameraID.value,
|
|
294
|
+
'Device ID': pucl.uci[index].dwDeviceID.value,
|
|
295
|
+
'Sensor ID': pucl.uci[index].dwSensorID.value,
|
|
296
|
+
'Status': pucl.uci[index].dwStatus.value,
|
|
297
|
+
'InUse': pucl.uci[index].dwInUse.value,
|
|
298
|
+
'Model': pucl.uci[index].Model.decode('utf-8'),
|
|
299
|
+
'Serial': pucl.uci[index].SerNo.decode('utf-8'),
|
|
300
|
+
'Driver': 'uEye',
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
if output:
|
|
304
|
+
print(cam_list)
|
|
305
|
+
return cam_list
|
|
306
|
+
|
|
307
|
+
def get_coded_info(self):
|
|
308
|
+
'''Reads out the data hard-coded in the non-volatile camera memory
|
|
309
|
+
and writes it to the data structure that cInfo points to
|
|
310
|
+
'''
|
|
311
|
+
nRet = ueye.is_GetCameraInfo(self.hCam, self.cInfo)
|
|
312
|
+
if nRet != ueye.IS_SUCCESS:
|
|
313
|
+
print('is_GetCameraInfo ERROR')
|
|
314
|
+
|
|
315
|
+
def get_device_info(self):
|
|
316
|
+
'''Gets the device info, used to get the sensor temp.'''
|
|
317
|
+
nRet = ueye.is_DeviceInfo(
|
|
318
|
+
self.hCam,
|
|
319
|
+
ueye.IS_DEVICE_INFO_CMD_GET_DEVICE_INFO,
|
|
320
|
+
self.dInfo,
|
|
321
|
+
ueye.sizeof(self.dInfo),
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
if nRet != ueye.IS_SUCCESS:
|
|
325
|
+
print('is_DeviceInfo ERROR')
|
|
326
|
+
|
|
327
|
+
def get_temperature(self):
|
|
328
|
+
'''Reads out the sensor temperature value
|
|
329
|
+
|
|
330
|
+
Returns
|
|
331
|
+
-------
|
|
332
|
+
float
|
|
333
|
+
camera sensor temperature in C.
|
|
334
|
+
'''
|
|
335
|
+
self.get_device_info()
|
|
336
|
+
self.temperature = (
|
|
337
|
+
(self.dInfo.infoDevHeartbeat.wTemperature.value >> 4) & 127
|
|
338
|
+
) * 1.0 + ((self.dInfo.infoDevHeartbeat.wTemperature.value & 15) / 10.0)
|
|
339
|
+
return self.temperature
|
|
340
|
+
|
|
341
|
+
def get_sensor_info(self):
|
|
342
|
+
'''You can query additional information about
|
|
343
|
+
the sensor type used in the camera
|
|
344
|
+
'''
|
|
345
|
+
nRet = ueye.is_GetSensorInfo(self.hCam, self.sInfo)
|
|
346
|
+
if nRet != ueye.IS_SUCCESS:
|
|
347
|
+
print('is_GetSensorInfo ERROR')
|
|
348
|
+
|
|
349
|
+
def reset_to_default(self):
|
|
350
|
+
'''Resets all parameters to the camera-specific defaults
|
|
351
|
+
as specified by the driver.
|
|
352
|
+
|
|
353
|
+
By default, the camera uses full resolution, a medium speed
|
|
354
|
+
and color level gain values adapted to daylight exposure.
|
|
355
|
+
'''
|
|
356
|
+
nRet = ueye.is_ResetToDefault(self.hCam)
|
|
357
|
+
if nRet != ueye.IS_SUCCESS:
|
|
358
|
+
print('is_ResetToDefault ERROR')
|
|
359
|
+
|
|
360
|
+
def set_display_mode(self, mode=ueye.IS_SET_DM_DIB):
|
|
361
|
+
'''Captures an image in system memory (RAM).
|
|
362
|
+
|
|
363
|
+
Using is_RenderBitmap(), you can define the image display (default).
|
|
364
|
+
|
|
365
|
+
Parameters
|
|
366
|
+
----------
|
|
367
|
+
mode : [type], optional
|
|
368
|
+
Capture mode, by default ueye.IS_SET_DM_DIB
|
|
369
|
+
captures an image in system memory (RAM).
|
|
370
|
+
|
|
371
|
+
Returns
|
|
372
|
+
-------
|
|
373
|
+
int
|
|
374
|
+
is_SetDisplayMode return code
|
|
375
|
+
'''
|
|
376
|
+
nRet = ueye.is_SetDisplayMode(self.hCam, mode)
|
|
377
|
+
return nRet
|
|
378
|
+
|
|
379
|
+
def set_color_mode(self):
|
|
380
|
+
'''Set the right color mode, by camera default.'''
|
|
381
|
+
# self.color_mode = ueye.is_SetColorMode(
|
|
382
|
+
# self.hCam, ueye.IS_GET_COLOR_MODE)
|
|
383
|
+
nCmode = int.from_bytes(self.sInfo.nColorMode.value, byteorder='big')
|
|
384
|
+
nRet = ueye.is_DeviceFeature(
|
|
385
|
+
self.hCam,
|
|
386
|
+
ueye.IS_DEVICE_FEATURE_CMD_GET_SUPPORTED_SENSOR_BIT_DEPTHS,
|
|
387
|
+
self.supported_bit_depth,
|
|
388
|
+
sizeof(self.supported_bit_depth),
|
|
389
|
+
)
|
|
390
|
+
print('nRet', nRet)
|
|
391
|
+
if nCmode == ueye.IS_COLORMODE_BAYER:
|
|
392
|
+
# setup the color depth to the current windows setting
|
|
393
|
+
ueye.is_GetColorDepth(self.hCam, self.bit_depth, self.color_mode)
|
|
394
|
+
self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
|
|
395
|
+
|
|
396
|
+
elif nCmode == ueye.IS_COLORMODE_CBYCRY:
|
|
397
|
+
# for color camera models use RGB32 mode
|
|
398
|
+
self.color_mode = ueye.IS_CM_BGRA8_PACKED
|
|
399
|
+
self.bit_depth = ueye.INT(32)
|
|
400
|
+
self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
|
|
401
|
+
|
|
402
|
+
elif nCmode == ueye.IS_COLORMODE_MONOCHROME:
|
|
403
|
+
# for mono camera models that uses CM_MONO12 mode
|
|
404
|
+
print('Sbit', self.supported_bit_depth)
|
|
405
|
+
if nRet == ueye.IS_SUCCESS:
|
|
406
|
+
if (self.supported_bit_depth and ueye.IS_SENSOR_BIT_DEPTH_12_BIT) != 0:
|
|
407
|
+
self.color_mode = ueye.IS_CM_MONO12
|
|
408
|
+
self.bit_depth = ueye.INT(12)
|
|
409
|
+
self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
|
|
410
|
+
elif (
|
|
411
|
+
self.supported_bit_depth and ueye.IS_SENSOR_BIT_DEPTH_10_BIT
|
|
412
|
+
) != 0:
|
|
413
|
+
self.color_mode = ueye.IS_CM_MONO10
|
|
414
|
+
self.bit_depth = ueye.INT(10)
|
|
415
|
+
self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
|
|
416
|
+
elif (self.supported_bit_depth and ueye.IS_SENSOR_BIT_DEPTH_8_BIT) != 0:
|
|
417
|
+
self.color_mode = ueye.IS_CM_MONO8
|
|
418
|
+
self.bit_depth = ueye.INT(8)
|
|
419
|
+
self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
|
|
420
|
+
else:
|
|
421
|
+
self.color_mode = ueye.IS_CM_MONO8
|
|
422
|
+
self.bit_depth = ueye.INT(8)
|
|
423
|
+
self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
|
|
424
|
+
|
|
425
|
+
else:
|
|
426
|
+
# for monochrome camera models use Y8 mode
|
|
427
|
+
self.color_mode = ueye.IS_CM_MONO8
|
|
428
|
+
self.bit_depth = ueye.INT(8)
|
|
429
|
+
self.bytes_per_pixel = int(np.ceil(self.bit_depth / 8))
|
|
430
|
+
print(
|
|
431
|
+
'Else: ',
|
|
432
|
+
)
|
|
433
|
+
print('\tcolor_mode: \t\t', formats_strs[self.color_mode])
|
|
434
|
+
print('\tbit_depth: \t\t', self.bit_depth)
|
|
435
|
+
print('\tbytes_per_pixel: \t\t', self.bytes_per_pixel)
|
|
436
|
+
|
|
437
|
+
nRet = ueye.is_SetColorMode(self.hCam, self.color_mode)
|
|
438
|
+
|
|
439
|
+
def get_roi(self):
|
|
440
|
+
'''Can be used to get the size and position
|
|
441
|
+
of an "area of interest" (ROI) within an image.
|
|
442
|
+
|
|
443
|
+
For ROI rectangle check IDS_Camera.rectROI
|
|
444
|
+
|
|
445
|
+
Returns
|
|
446
|
+
-------
|
|
447
|
+
int
|
|
448
|
+
is_ROI return code.
|
|
449
|
+
'''
|
|
450
|
+
nRet = ueye.is_AOI(
|
|
451
|
+
self.hCam,
|
|
452
|
+
ueye.IS_AOI_IMAGE_GET_AOI,
|
|
453
|
+
self.rectROI,
|
|
454
|
+
ueye.sizeof(self.rectROI),
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
if nRet != ueye.IS_SUCCESS:
|
|
458
|
+
print('is_AOI GET ERROR')
|
|
459
|
+
|
|
460
|
+
self.width = self.rectROI.s32Width
|
|
461
|
+
self.height = self.rectROI.s32Height
|
|
462
|
+
return nRet
|
|
463
|
+
|
|
464
|
+
def set_roi(self, x, y, width, height):
|
|
465
|
+
'''Sets the size and position of an
|
|
466
|
+
"area of interest"(ROI) within an image.
|
|
467
|
+
|
|
468
|
+
Parameters
|
|
469
|
+
----------
|
|
470
|
+
x : int
|
|
471
|
+
ROI x position.
|
|
472
|
+
y : int
|
|
473
|
+
ROI y position.
|
|
474
|
+
width : int
|
|
475
|
+
ROI width.
|
|
476
|
+
height : int
|
|
477
|
+
ROI height.
|
|
478
|
+
|
|
479
|
+
Returns
|
|
480
|
+
-------
|
|
481
|
+
int
|
|
482
|
+
is_AOI return code.
|
|
483
|
+
'''
|
|
484
|
+
self.set_rectROI.s32X.value = x
|
|
485
|
+
self.set_rectROI.s32Y.value = y
|
|
486
|
+
self.set_rectROI.s32Width.value = width
|
|
487
|
+
self.set_rectROI.s32Height.value = height
|
|
488
|
+
|
|
489
|
+
nRet = ueye.is_AOI(
|
|
490
|
+
self.hCam,
|
|
491
|
+
ueye.IS_AOI_IMAGE_SET_AOI,
|
|
492
|
+
self.set_rectROI,
|
|
493
|
+
ueye.sizeof(self.set_rectROI),
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
if nRet != ueye.IS_SUCCESS:
|
|
497
|
+
print('is_AOI SET ERROR')
|
|
498
|
+
|
|
499
|
+
self.width = self.set_rectROI.s32Width
|
|
500
|
+
self.height = self.set_rectROI.s32Height
|
|
501
|
+
|
|
502
|
+
return nRet
|
|
503
|
+
|
|
504
|
+
def reset_roi(self):
|
|
505
|
+
'''Resets the ROI.
|
|
506
|
+
|
|
507
|
+
Returns
|
|
508
|
+
-------
|
|
509
|
+
int
|
|
510
|
+
is_AOI return code.
|
|
511
|
+
'''
|
|
512
|
+
nRet = ueye.is_AOI(
|
|
513
|
+
self.hCam,
|
|
514
|
+
ueye.IS_AOI_IMAGE_SET_AOI,
|
|
515
|
+
self.rectROI,
|
|
516
|
+
ueye.sizeof(self.rectROI),
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
if nRet != ueye.IS_SUCCESS:
|
|
520
|
+
print('is_AOI RESET ERROR')
|
|
521
|
+
|
|
522
|
+
self.width = self.rectROI.s32Width
|
|
523
|
+
self.height = self.rectROI.s32Height
|
|
524
|
+
|
|
525
|
+
return nRet
|
|
526
|
+
|
|
527
|
+
def set_pixel_clock(self, value):
|
|
528
|
+
"""Sets the camera's pixel clock speed.
|
|
529
|
+
|
|
530
|
+
Parameters
|
|
531
|
+
----------
|
|
532
|
+
value : uint
|
|
533
|
+
The supported clock speed to set.
|
|
534
|
+
|
|
535
|
+
Returns
|
|
536
|
+
-------
|
|
537
|
+
int
|
|
538
|
+
is_PixelClock return code.
|
|
539
|
+
"""
|
|
540
|
+
set = (ueye.c_uint * 1)(value)
|
|
541
|
+
nRet = ueye.is_PixelClock(
|
|
542
|
+
self.hCam, ueye.IS_PIXELCLOCK_CMD_SET, set, ueye.sizeof(set)
|
|
543
|
+
)
|
|
544
|
+
|
|
545
|
+
if nRet != ueye.IS_SUCCESS:
|
|
546
|
+
print('is_PixelClock ERROR')
|
|
547
|
+
|
|
548
|
+
return nRet
|
|
549
|
+
|
|
550
|
+
def get_pixel_clock_info(self, output=True):
|
|
551
|
+
'''Gets the pixel clock value, default,
|
|
552
|
+
and supported values list.
|
|
553
|
+
|
|
554
|
+
Parameters
|
|
555
|
+
----------
|
|
556
|
+
output : bool, optional
|
|
557
|
+
prints out results to terminal, by default True
|
|
558
|
+
'''
|
|
559
|
+
|
|
560
|
+
self.get_pixel_clock(output)
|
|
561
|
+
|
|
562
|
+
# Get default pixel clock
|
|
563
|
+
nRet = ueye.is_PixelClock(
|
|
564
|
+
self.hCam,
|
|
565
|
+
ueye.IS_PIXELCLOCK_CMD_GET_DEFAULT,
|
|
566
|
+
self.pixel_clock_default,
|
|
567
|
+
ueye.sizeof(self.pixel_clock_default),
|
|
568
|
+
)
|
|
569
|
+
|
|
570
|
+
if nRet != ueye.IS_SUCCESS:
|
|
571
|
+
print('is_PixelClock Default ERROR')
|
|
572
|
+
elif output:
|
|
573
|
+
print('Default ' + str(self.pixel_clock_default.value))
|
|
574
|
+
|
|
575
|
+
nRet = ueye.is_PixelClock(
|
|
576
|
+
self.hCam,
|
|
577
|
+
ueye.IS_PIXELCLOCK_CMD_GET_RANGE,
|
|
578
|
+
self.pixel_clock_range,
|
|
579
|
+
ueye.sizeof(self.pixel_clock_range),
|
|
580
|
+
)
|
|
581
|
+
|
|
582
|
+
if nRet != ueye.IS_SUCCESS:
|
|
583
|
+
print('is_PixelClock Range ERROR')
|
|
584
|
+
elif output:
|
|
585
|
+
print('Min ' + str(self.pixel_clock_range[0].value))
|
|
586
|
+
print('Max ' + str(self.pixel_clock_range[1].value))
|
|
587
|
+
|
|
588
|
+
nRet = ueye.is_PixelClock(
|
|
589
|
+
self.hCam,
|
|
590
|
+
ueye.IS_PIXELCLOCK_CMD_GET_NUMBER,
|
|
591
|
+
self.pixel_clock_count,
|
|
592
|
+
ueye.sizeof(self.pixel_clock_count),
|
|
593
|
+
)
|
|
594
|
+
|
|
595
|
+
if nRet != ueye.IS_SUCCESS:
|
|
596
|
+
print('is_PixelClock Count ERROR')
|
|
597
|
+
else:
|
|
598
|
+
if output:
|
|
599
|
+
print('Count ' + str(self.pixel_clock_count.value))
|
|
600
|
+
|
|
601
|
+
self.pixel_clock_list = (ueye.c_uint * self.pixel_clock_count.value)()
|
|
602
|
+
|
|
603
|
+
nRet = ueye.is_PixelClock(
|
|
604
|
+
self.hCam,
|
|
605
|
+
ueye.IS_PIXELCLOCK_CMD_GET_LIST,
|
|
606
|
+
self.pixel_clock_list,
|
|
607
|
+
self.pixel_clock_count * ueye.sizeof(c_uint),
|
|
608
|
+
)
|
|
609
|
+
|
|
610
|
+
if nRet != ueye.IS_SUCCESS:
|
|
611
|
+
print('is_PixelClock List ERROR')
|
|
612
|
+
elif output:
|
|
613
|
+
for clk in self.pixel_clock_list:
|
|
614
|
+
print('List ' + str(clk.value))
|
|
615
|
+
print()
|
|
616
|
+
|
|
617
|
+
def get_pixel_clock(self, output=True):
|
|
618
|
+
'''Gets the current pixel clock speed.
|
|
619
|
+
|
|
620
|
+
Parameters
|
|
621
|
+
----------
|
|
622
|
+
output : bool, optional
|
|
623
|
+
print out to terminal, by default True
|
|
624
|
+
|
|
625
|
+
Returns
|
|
626
|
+
-------
|
|
627
|
+
int
|
|
628
|
+
pixel clock speed in MHz.
|
|
629
|
+
'''
|
|
630
|
+
nRet = ueye.is_PixelClock(
|
|
631
|
+
self.hCam,
|
|
632
|
+
ueye.IS_PIXELCLOCK_CMD_GET,
|
|
633
|
+
self.pixel_clock,
|
|
634
|
+
ueye.sizeof(self.pixel_clock),
|
|
635
|
+
)
|
|
636
|
+
|
|
637
|
+
if nRet != ueye.IS_SUCCESS:
|
|
638
|
+
print('is_PixelClock ERROR')
|
|
639
|
+
elif output:
|
|
640
|
+
print(f'Pixel Clock {self.pixel_clock.value} MHz')
|
|
641
|
+
return self.pixel_clock.value
|
|
642
|
+
|
|
643
|
+
def get_exposure_range(self, output=True):
|
|
644
|
+
'''Gets exposure range
|
|
645
|
+
|
|
646
|
+
Parameters
|
|
647
|
+
----------
|
|
648
|
+
output : bool, optional
|
|
649
|
+
[description], by default True
|
|
650
|
+
'''
|
|
651
|
+
nRet = ueye.is_Exposure(
|
|
652
|
+
self.hCam,
|
|
653
|
+
ueye.IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE,
|
|
654
|
+
self.exposure_range,
|
|
655
|
+
ueye.sizeof(self.exposure_range),
|
|
656
|
+
)
|
|
657
|
+
if nRet != ueye.IS_SUCCESS:
|
|
658
|
+
print('is_Exposure Range ERROR')
|
|
659
|
+
elif output:
|
|
660
|
+
print('Exposure')
|
|
661
|
+
print('Min ' + str(self.exposure_range[0].value))
|
|
662
|
+
print('Max ' + str(self.exposure_range[1].value))
|
|
663
|
+
print('Inc ' + str(self.exposure_range[2].value))
|
|
664
|
+
print()
|
|
665
|
+
|
|
666
|
+
# Get exposure
|
|
667
|
+
def get_exposure(self, output=True):
|
|
668
|
+
nRet = ueye.is_Exposure(
|
|
669
|
+
self.hCam,
|
|
670
|
+
ueye.IS_EXPOSURE_CMD_GET_EXPOSURE,
|
|
671
|
+
self.exposure_current,
|
|
672
|
+
ueye.sizeof(self.exposure_current),
|
|
673
|
+
)
|
|
674
|
+
if nRet != ueye.IS_SUCCESS:
|
|
675
|
+
print('is_Exposure Current ERROR')
|
|
676
|
+
elif output:
|
|
677
|
+
print('Current Exposure ' + str(self.exposure_current.value))
|
|
678
|
+
print()
|
|
679
|
+
return self.exposure_current.value
|
|
680
|
+
|
|
681
|
+
# Set exposure
|
|
682
|
+
def set_exposure(self, value):
|
|
683
|
+
nRet = ueye.is_Exposure(
|
|
684
|
+
self.hCam,
|
|
685
|
+
ueye.IS_EXPOSURE_CMD_SET_EXPOSURE,
|
|
686
|
+
ueye.c_double(max(min(value, self.exposure_range[1].value), 0)),
|
|
687
|
+
ueye.sizeof(ueye.c_double),
|
|
688
|
+
)
|
|
689
|
+
if nRet != ueye.IS_SUCCESS:
|
|
690
|
+
print('is_Exposure Set ERROR')
|
|
691
|
+
else:
|
|
692
|
+
print('Exposure set to ' + str(self.get_exposure(False)))
|
|
693
|
+
print()
|
|
694
|
+
return nRet
|
|
695
|
+
|
|
696
|
+
# Get flash output info
|
|
697
|
+
def get_flash_range(self, output=True):
|
|
698
|
+
nRet = ueye.is_IO(
|
|
699
|
+
self.hCam,
|
|
700
|
+
ueye.IS_IO_CMD_FLASH_GET_PARAMS_MIN,
|
|
701
|
+
self.flash_min,
|
|
702
|
+
ueye.sizeof(self.flash_min),
|
|
703
|
+
)
|
|
704
|
+
if nRet != ueye.IS_SUCCESS:
|
|
705
|
+
print('is_IO Flash Min ERROR')
|
|
706
|
+
elif output:
|
|
707
|
+
print('Flash Output')
|
|
708
|
+
print('Min Delay (us) ' + str(self.flash_min.s32Delay.value))
|
|
709
|
+
print('Min Duration (us) ' + str(self.flash_min.u32Duration.value))
|
|
710
|
+
print()
|
|
711
|
+
|
|
712
|
+
nRet = ueye.is_IO(
|
|
713
|
+
self.hCam,
|
|
714
|
+
ueye.IS_IO_CMD_FLASH_GET_PARAMS_MAX,
|
|
715
|
+
self.flash_max,
|
|
716
|
+
ueye.sizeof(self.flash_max),
|
|
717
|
+
)
|
|
718
|
+
if nRet != ueye.IS_SUCCESS:
|
|
719
|
+
print('is_IO Flash Max ERROR')
|
|
720
|
+
elif output:
|
|
721
|
+
print('Max Delay (us) ' + str(self.flash_max.s32Delay.value))
|
|
722
|
+
print('Max Duration (us) ' + str(self.flash_max.u32Duration.value))
|
|
723
|
+
print()
|
|
724
|
+
|
|
725
|
+
nRet = ueye.is_IO(
|
|
726
|
+
self.hCam,
|
|
727
|
+
ueye.IS_IO_CMD_FLASH_GET_PARAMS_INC,
|
|
728
|
+
self.flash_inc,
|
|
729
|
+
ueye.sizeof(self.flash_inc),
|
|
730
|
+
)
|
|
731
|
+
if nRet != ueye.IS_SUCCESS:
|
|
732
|
+
print('is_IO Flash Inc. ERROR')
|
|
733
|
+
elif output:
|
|
734
|
+
print('Inc. Delay (us) ' + str(self.flash_inc.s32Delay.value))
|
|
735
|
+
print('Inc. Duration (us) ' + str(self.flash_inc.u32Duration.value))
|
|
736
|
+
print()
|
|
737
|
+
|
|
738
|
+
self.get_flash_params(output)
|
|
739
|
+
|
|
740
|
+
def get_flash_params(self, output=True):
|
|
741
|
+
nRet = ueye.is_IO(
|
|
742
|
+
self.hCam,
|
|
743
|
+
ueye.IS_IO_CMD_FLASH_GET_PARAMS,
|
|
744
|
+
self.flash_cur,
|
|
745
|
+
ueye.sizeof(self.flash_cur),
|
|
746
|
+
)
|
|
747
|
+
if nRet != ueye.IS_SUCCESS:
|
|
748
|
+
print('is_IO Flash Current ERROR')
|
|
749
|
+
elif output:
|
|
750
|
+
print('Current Delay (us) ' + str(self.flash_cur.s32Delay.value))
|
|
751
|
+
print('Current Duration (us) ' + str(self.flash_cur.u32Duration.value))
|
|
752
|
+
print()
|
|
753
|
+
|
|
754
|
+
# Set current flash parameters
|
|
755
|
+
def set_flash_params(self, delay, duration):
|
|
756
|
+
params = ueye.IO_FLASH_PARAMS()
|
|
757
|
+
delay = int(delay)
|
|
758
|
+
duration = ueye.UINT(duration)
|
|
759
|
+
if duration != 0:
|
|
760
|
+
params.u32Duration.value = max(
|
|
761
|
+
min(duration, self.flash_max.u32Duration.value),
|
|
762
|
+
self.flash_min.u32Duration.value,
|
|
763
|
+
)
|
|
764
|
+
else:
|
|
765
|
+
params.u32Duration.value = 0
|
|
766
|
+
|
|
767
|
+
if delay > 0:
|
|
768
|
+
params.s32Delay.value = max(
|
|
769
|
+
min(delay, self.flash_max.s32Delay.value), self.flash_min.s32Delay.value
|
|
770
|
+
)
|
|
771
|
+
else:
|
|
772
|
+
params.s32Delay.value = 0
|
|
773
|
+
|
|
774
|
+
nRet = ueye.is_IO(
|
|
775
|
+
self.hCam, ueye.IS_IO_CMD_FLASH_SET_PARAMS, params, ueye.sizeof(params)
|
|
776
|
+
)
|
|
777
|
+
if nRet != ueye.IS_SUCCESS:
|
|
778
|
+
print('set_flash_params ERROR')
|
|
779
|
+
else:
|
|
780
|
+
self.get_flash_params()
|
|
781
|
+
return nRet
|
|
782
|
+
|
|
783
|
+
# Set current flash mode
|
|
784
|
+
def set_flash_mode(self, mode):
|
|
785
|
+
mode = ueye.c_uint(mode)
|
|
786
|
+
nRet = ueye.is_IO(
|
|
787
|
+
self.hCam, ueye.IS_IO_CMD_FLASH_SET_MODE, mode, ueye.sizeof(mode)
|
|
788
|
+
)
|
|
789
|
+
if nRet != ueye.IS_SUCCESS:
|
|
790
|
+
print('is_IO Set Flash Mode ERROR')
|
|
791
|
+
return nRet
|
|
792
|
+
|
|
793
|
+
# Get current flash mode
|
|
794
|
+
def get_flash_mode(self, output=False):
|
|
795
|
+
nRet = ueye.is_IO(
|
|
796
|
+
self.hCam,
|
|
797
|
+
ueye.IS_IO_CMD_FLASH_GET_MODE,
|
|
798
|
+
self.flash_mode,
|
|
799
|
+
ueye.sizeof(self.flash_mode),
|
|
800
|
+
)
|
|
801
|
+
if nRet != ueye.IS_SUCCESS:
|
|
802
|
+
print('is_IO Get Flash Mode ERROR')
|
|
803
|
+
else:
|
|
804
|
+
print(
|
|
805
|
+
list(self.FLASH_MODES.keys())[
|
|
806
|
+
list(self.FLASH_MODES.values()).index(self.flash_mode.value)
|
|
807
|
+
]
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
# Get framerate range
|
|
811
|
+
def get_framerate_range(self, output=True):
|
|
812
|
+
nRet = ueye.is_GetFrameTimeRange(
|
|
813
|
+
self.hCam, self.min_framerate, self.max_framerate, self.increment_framerate
|
|
814
|
+
)
|
|
815
|
+
if nRet != ueye.IS_SUCCESS:
|
|
816
|
+
print('is_GetFrameTimeRange ERROR')
|
|
817
|
+
else:
|
|
818
|
+
temp = self.max_framerate.value
|
|
819
|
+
self.max_framerate.value = 1 / self.min_framerate.value
|
|
820
|
+
self.min_framerate.value = 1 / temp
|
|
821
|
+
if output:
|
|
822
|
+
print('FrameRate')
|
|
823
|
+
print('Min ' + str(self.min_framerate.value))
|
|
824
|
+
print('Max ' + str(self.max_framerate.value))
|
|
825
|
+
print()
|
|
826
|
+
return np.array([self.min_framerate.value, self.max_framerate.value])
|
|
827
|
+
|
|
828
|
+
# Get current framerate
|
|
829
|
+
def get_framerate(self, output=True):
|
|
830
|
+
nRet = ueye.is_GetFramesPerSecond(self.hCam, self.current_framerate)
|
|
831
|
+
if nRet != ueye.IS_SUCCESS:
|
|
832
|
+
print('is_GetFramesPerSecond ERROR')
|
|
833
|
+
elif output:
|
|
834
|
+
print('Current FrameRate ' + str(self.current_framerate.value))
|
|
835
|
+
print()
|
|
836
|
+
return self.current_framerate.value
|
|
837
|
+
|
|
838
|
+
# Set current framerate
|
|
839
|
+
def set_framerate(self, value):
|
|
840
|
+
nRet = ueye.is_SetFrameRate(
|
|
841
|
+
self.hCam,
|
|
842
|
+
ueye.c_double(
|
|
843
|
+
max(min(value, self.max_framerate.value), self.min_framerate.value)
|
|
844
|
+
),
|
|
845
|
+
self.current_framerate,
|
|
846
|
+
)
|
|
847
|
+
if nRet != ueye.IS_SUCCESS:
|
|
848
|
+
print('is_SetFrameRate ERROR')
|
|
849
|
+
else:
|
|
850
|
+
print('FrameRate set to ' + str(self.current_framerate.value))
|
|
851
|
+
print()
|
|
852
|
+
return nRet
|
|
853
|
+
|
|
854
|
+
# get trigger mode
|
|
855
|
+
def get_trigger_mode(self):
|
|
856
|
+
nRet = ueye.is_SetExternalTrigger(self.hCam, ueye.IS_GET_EXTERNALTRIGGER)
|
|
857
|
+
if nRet == ueye.IS_SET_TRIGGER_OFF:
|
|
858
|
+
print('Trigger Off')
|
|
859
|
+
elif nRet == ueye.IS_SET_TRIGGER_SOFTWARE:
|
|
860
|
+
print('Software Trigger')
|
|
861
|
+
elif nRet == ueye.IS_SET_TRIGGER_HI_LO:
|
|
862
|
+
print('Falling edge external trigger')
|
|
863
|
+
elif nRet == ueye.IS_SET_TRIGGER_LO_HI:
|
|
864
|
+
print('Rising edge external trigger')
|
|
865
|
+
else:
|
|
866
|
+
print('NA')
|
|
867
|
+
self.trigger_mode = nRet
|
|
868
|
+
return nRet
|
|
869
|
+
|
|
870
|
+
def set_trigger_mode(self, mode):
|
|
871
|
+
return ueye.is_SetExternalTrigger(self.hCam, mode)
|
|
872
|
+
|
|
873
|
+
# Allocates an image memory for an image having its dimensions defined by
|
|
874
|
+
# width and height and its color depth defined by bit_depth
|
|
875
|
+
def allocate_memory(self):
|
|
876
|
+
if len(self.MemInfo) > 0:
|
|
877
|
+
self.free_memory()
|
|
878
|
+
|
|
879
|
+
self.pcImageMemory = ueye.c_mem_p()
|
|
880
|
+
self.MemID = ueye.c_int(0)
|
|
881
|
+
self.MemInfo.append([self.pcImageMemory, self.MemID])
|
|
882
|
+
nRet = ueye.is_AllocImageMem(
|
|
883
|
+
self.hCam,
|
|
884
|
+
self.width,
|
|
885
|
+
self.height,
|
|
886
|
+
self.bit_depth,
|
|
887
|
+
self.pcImageMemory,
|
|
888
|
+
self.MemID,
|
|
889
|
+
)
|
|
890
|
+
if nRet != ueye.IS_SUCCESS:
|
|
891
|
+
print('is_AllocImageMem ERROR')
|
|
892
|
+
else:
|
|
893
|
+
# Makes the specified image memory the active memory
|
|
894
|
+
nRet = ueye.is_SetImageMem(self.hCam, self.pcImageMemory, self.MemID)
|
|
895
|
+
if nRet != ueye.IS_SUCCESS:
|
|
896
|
+
print('is_SetImageMem ERROR')
|
|
897
|
+
else:
|
|
898
|
+
self.memory_allocated = True
|
|
899
|
+
|
|
900
|
+
# Activates the camera's live video mode (free run mode)
|
|
901
|
+
def start_live_capture(self):
|
|
902
|
+
nRet = ueye.is_CaptureVideo(self.hCam, ueye.IS_DONT_WAIT)
|
|
903
|
+
if nRet != ueye.IS_SUCCESS:
|
|
904
|
+
print('is_CaptureVideo ERROR')
|
|
905
|
+
else:
|
|
906
|
+
self.capture_video = True
|
|
907
|
+
return nRet
|
|
908
|
+
|
|
909
|
+
# Stops the camera's live video mode (free run mode)
|
|
910
|
+
def stop_live_capture(self):
|
|
911
|
+
nRet = ueye.is_StopLiveVideo(self.hCam, ueye.IS_FORCE_VIDEO_STOP)
|
|
912
|
+
if nRet != ueye.IS_SUCCESS:
|
|
913
|
+
print('is_StopLiveVideo ERROR')
|
|
914
|
+
else:
|
|
915
|
+
self.capture_video = False
|
|
916
|
+
return nRet
|
|
917
|
+
|
|
918
|
+
def allocate_memory_buffer(self, buffers: int = 100):
|
|
919
|
+
if len(self.MemInfo) > 0:
|
|
920
|
+
self.free_memory()
|
|
921
|
+
|
|
922
|
+
for x in range(buffers):
|
|
923
|
+
self.MemInfo.append([ueye.c_mem_p(), ueye.c_int(0)])
|
|
924
|
+
ret = ueye.is_AllocImageMem(
|
|
925
|
+
self.hCam,
|
|
926
|
+
self.width,
|
|
927
|
+
self.height,
|
|
928
|
+
self.bit_depth,
|
|
929
|
+
self.MemInfo[x][0],
|
|
930
|
+
self.MemInfo[x][1],
|
|
931
|
+
)
|
|
932
|
+
ret = ueye.is_AddToSequence(
|
|
933
|
+
self.hCam, self.MemInfo[x][0], self.MemInfo[x][1]
|
|
934
|
+
)
|
|
935
|
+
|
|
936
|
+
ret = ueye.is_InitImageQueue(self.hCam, c_int(0))
|
|
937
|
+
|
|
938
|
+
def unlock_buffer(self):
|
|
939
|
+
return ueye.is_UnlockSeqBuf(self.hCam, self.current_id, self.current_buffer)
|
|
940
|
+
|
|
941
|
+
def get_pitch(self):
|
|
942
|
+
x = ueye.c_int()
|
|
943
|
+
y = ueye.c_int()
|
|
944
|
+
bits = ueye.c_int()
|
|
945
|
+
|
|
946
|
+
pc_mem = ueye.c_mem_p()
|
|
947
|
+
pid = ueye.c_int()
|
|
948
|
+
ueye.is_GetActiveImageMem(self.hCam, pc_mem, pid)
|
|
949
|
+
ueye.is_InquireImageMem(self.hCam, pc_mem, pid, x, y, bits, self.pitch)
|
|
950
|
+
|
|
951
|
+
return self.pitch.value
|
|
952
|
+
|
|
953
|
+
# Releases an image memory that was allocated using is_AllocImageMem()
|
|
954
|
+
# and removes it from the driver management
|
|
955
|
+
def free_memory(self):
|
|
956
|
+
nRet = 0
|
|
957
|
+
for x in range(len(self.MemInfo)):
|
|
958
|
+
nRet += ueye.is_FreeImageMem(
|
|
959
|
+
self.hCam, self.MemInfo[x][0], self.MemInfo[x][1]
|
|
960
|
+
)
|
|
961
|
+
self.MemInfo.clear()
|
|
962
|
+
self.memory_allocated = False
|
|
963
|
+
return nRet
|
|
964
|
+
|
|
965
|
+
def wait_for_next_image(self, wait=0, log=True):
|
|
966
|
+
nret = ueye.is_WaitForNextImage(
|
|
967
|
+
self.hCam, wait, self.current_buffer, self.current_id
|
|
968
|
+
)
|
|
969
|
+
if nret == ueye.IS_SUCCESS:
|
|
970
|
+
if log:
|
|
971
|
+
logging.debug(f'is_WaitForNextImage, IS_SUCCESS: {nret}')
|
|
972
|
+
elif nret == ueye.IS_TIMED_OUT:
|
|
973
|
+
if log:
|
|
974
|
+
logging.debug(f'is_WaitForNextImage, IS_TIMED_OUT: {nret}')
|
|
975
|
+
elif nret == ueye.IS_CAPTURE_STATUS:
|
|
976
|
+
if log:
|
|
977
|
+
logging.debug(f'is_WaitForNextImage, IS_CAPTURE_STATUS: {nret}')
|
|
978
|
+
self.CaptureStatusInfo = ueye.UEYE_CAPTURE_STATUS_INFO()
|
|
979
|
+
nRet = ueye.is_CaptureStatus(
|
|
980
|
+
self.hCam,
|
|
981
|
+
ueye.IS_CAPTURE_STATUS_INFO_CMD_GET,
|
|
982
|
+
self.CaptureStatusInfo,
|
|
983
|
+
sizeof(self.CaptureStatusInfo),
|
|
984
|
+
)
|
|
985
|
+
if nRet == ueye.IS_SUCCESS:
|
|
986
|
+
ueye.is_CaptureStatus(
|
|
987
|
+
self.hCam, ueye.IS_CAPTURE_STATUS_INFO_CMD_RESET, None, 0
|
|
988
|
+
)
|
|
989
|
+
return nret
|
|
990
|
+
|
|
991
|
+
# Enables the queue mode for existing image memory sequences
|
|
992
|
+
def enable_queue_mode(self):
|
|
993
|
+
nRet = ueye.is_InquireImageMem(
|
|
994
|
+
self.hCam,
|
|
995
|
+
self.pcImageMemory,
|
|
996
|
+
self.MemID,
|
|
997
|
+
self.width,
|
|
998
|
+
self.height,
|
|
999
|
+
self.bit_depth,
|
|
1000
|
+
self.pitch,
|
|
1001
|
+
)
|
|
1002
|
+
if nRet != ueye.IS_SUCCESS:
|
|
1003
|
+
print('is_InquireImageMem ERROR')
|
|
1004
|
+
|
|
1005
|
+
return nRet
|
|
1006
|
+
|
|
1007
|
+
def get_data(self):
|
|
1008
|
+
# In order to display the image in an OpenCV window we need to...
|
|
1009
|
+
# ...extract the data of our image memory
|
|
1010
|
+
return ueye.get_data(
|
|
1011
|
+
self.current_buffer,
|
|
1012
|
+
self.width,
|
|
1013
|
+
self.height,
|
|
1014
|
+
self.bit_depth,
|
|
1015
|
+
self.pitch,
|
|
1016
|
+
copy=False,
|
|
1017
|
+
)
|
|
1018
|
+
|
|
1019
|
+
# Disables the hCam camera handle and releases the data structures
|
|
1020
|
+
# and memory areas taken up by the uEye camera
|
|
1021
|
+
def dispose(self):
|
|
1022
|
+
nRet = ueye.is_ExitCamera(self.hCam)
|
|
1023
|
+
return nRet
|