IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
datatypes.py
Go to the documentation of this file.
1from __future__ import annotations
2
3import ctypes
4from enum import Enum
5
6
7class peak_icv_status(Enum):
8 PEAK_ICV_STATUS_SUCCESS = 0
9 PEAK_ICV_STATUS_LIBRARY_NOT_INITIALIZED = 1
10 PEAK_ICV_STATUS_DYNAMIC_DEPENDENCY_MISSING = 2
11 PEAK_ICV_STATUS_MISMATCH = 3
12 PEAK_ICV_STATUS_NOT_SUPPORTED = 4
13 PEAK_ICV_STATUS_NOT_POSSIBLE = 5
14 PEAK_ICV_STATUS_NULL_POINTER = 6
15 PEAK_ICV_STATUS_INVALID_HANDLE = 7
16 PEAK_ICV_STATUS_OUT_OF_RANGE = 8
17 PEAK_ICV_STATUS_MATH_ERROR = 9
18 PEAK_ICV_STATUS_TARGET_NOT_FOUND = 10
19 PEAK_ICV_STATUS_CORRUPTED = 11
20 PEAK_ICV_STATUS_IO_ERROR = 12
21 PEAK_ICV_STATUS_INTERNAL_ERROR = 13
22 PEAK_ICV_STATUS_INVALID_BUFFER_SIZE = 14
23
24
26 PEAK_ICV_POINT_TYPE_XYZ = 0,
27 PEAK_ICV_POINT_TYPE_XYZ_I8 = 1,
28 PEAK_ICV_POINT_TYPE_XYZ_I10 = 2,
29 PEAK_ICV_POINT_TYPE_XYZ_I12 = 3,
30 PEAK_ICV_POINT_TYPE_XY = 4
31
32
33class peak_common_interval(ctypes.Structure):
34 _fields_ = [("minimum", ctypes.c_int32),
35 ("maximum", ctypes.c_int32)]
36
37
38class peak_common_interval_u(ctypes.Structure):
39 _fields_ = [("minimum", ctypes.c_uint32),
40 ("maximum", ctypes.c_uint32)]
41
42
43class peak_common_interval_f(ctypes.Structure):
44 _fields_ = [("minimum", ctypes.c_float),
45 ("maximum", ctypes.c_float)]
46
47
48class peak_common_range_u(ctypes.Structure):
49 _fields_ = [("minimum", ctypes.c_uint32),
50 ("maximum", ctypes.c_uint32),
51 ("increment", ctypes.c_uint32)]
52
53
54class peak_common_size(ctypes.Structure):
55 _fields_ = [("width", ctypes.c_uint32),
56 ("height", ctypes.c_uint32)]
57
58
59class peak_common_size_f(ctypes.Structure):
60 _fields_ = [("width", ctypes.c_float),
61 ("height", ctypes.c_float)]
62
63
64class peak_icv_drawing_options(ctypes.Structure):
65 _fields_ = [("color", ctypes.c_uint64),
66 ("opacity", ctypes.c_uint32),
67 ("line_width", ctypes.c_size_t)]
68
69
70class peak_icv_point(ctypes.Structure):
71 _fields_ = [("x", ctypes.c_int32),
72 ("y", ctypes.c_int32)]
73
74
75class peak_icv_point_u(ctypes.Structure):
76 _fields_ = [("x", ctypes.c_uint32),
77 ("y", ctypes.c_uint32)]
78
79
80class peak_icv_point_f(ctypes.Structure):
81 _fields_ = [("x", ctypes.c_float),
82 ("y", ctypes.c_float)]
83
84
85class peak_icv_point_xyz(ctypes.Structure):
86 _fields_ = [("x", ctypes.c_float),
87 ("y", ctypes.c_float),
88 ("z", ctypes.c_float),
89 ("_", ctypes.c_float)]
90
91
92class peak_icv_point_xyzi(ctypes.Structure):
93 _fields_ = [("x", ctypes.c_float),
94 ("y", ctypes.c_float),
95 ("z", ctypes.c_float),
96 ("i", ctypes.c_uint16)]
97
98
99class peak_common_rectangle(ctypes.Structure):
100 _fields_ = [("x", ctypes.c_int32),
101 ("y", ctypes.c_int32),
102 ("width", ctypes.c_uint32),
103 ("height", ctypes.c_uint32)]
104
105
106class peak_common_rectangle_u(ctypes.Structure):
107 _fields_ = [("x", ctypes.c_uint32),
108 ("y", ctypes.c_uint32),
109 ("width", ctypes.c_uint32),
110 ("height", ctypes.c_uint32)]
111
112
113class peak_common_rectangle_f(ctypes.Structure):
114 _fields_ = [("x", ctypes.c_float),
115 ("y", ctypes.c_float),
116 ("width", ctypes.c_float),
117 ("height", ctypes.c_float)]
118
119
120class peak_common_version(ctypes.Structure):
121 _fields_ = [("major", ctypes.c_uint32),
122 ("minor", ctypes.c_uint32),
123 ("patch", ctypes.c_uint32),
124 ("revision", ctypes.c_uint32)]
125
126
127class peak_icv_prism_distortion(ctypes.Structure):
128 _fields_ = [("coefficients", ctypes.c_double * 4)]
129
130
131class peak_icv_radial_distortion(ctypes.Structure):
132 _fields_ = [("coefficients", ctypes.c_double * 6)]
133
134
135class peak_icv_tangential_distortion(ctypes.Structure):
136 _fields_ = [("coefficients", ctypes.c_double * 2)]
137
138
139class peak_icv_tilt_distortion(ctypes.Structure):
140 _fields_ = [("coefficients", ctypes.c_double * 2)]
141
142
143class peak_icv_distortion_coefficients(ctypes.Structure):
144 _fields_ = [("radial_distortion", peak_icv_radial_distortion),
145 ("tangential_distortion", peak_icv_tangential_distortion),
146 ("prism_distortion", peak_icv_prism_distortion),
147 ("tilt_distortion", peak_icv_tilt_distortion)]
148
149
150class peak_icv_coordinate_system(ctypes.Structure):
151 _fields_ = [("origin", peak_icv_point_f),
152 ("x_axis", peak_icv_point_f),
153 ("y_axis", peak_icv_point_f),
154 ("z_axis", peak_icv_point_f)]
155
156
157class peak_icv_header(ctypes.Structure):
158 _fields_ = [("marker", ctypes.c_uint32),
159 ("type", ctypes.c_uint32),
160 ("flags", ctypes.c_uint32),
161 ("version", peak_common_version),
162 ("crc", ctypes.c_uint32)]
163
164
165peak_icv_binning = peak_icv_point_u
166
167
168class peak_icv_intrinsic_parameters(ctypes.Structure):
169 _fields_ = [
170 ("image_size", peak_common_size),
171 ("binning_factor", peak_icv_binning),
172 ("distortion_coefficients", peak_icv_distortion_coefficients),
173 ("focal_length_pixel_size_ratio", peak_icv_point_f),
174 ("principle_point", peak_icv_point_f)]
175
176
177class peak_icv_extrinsic_parameters(ctypes.Structure):
178 _fields_ = [("rotation", peak_icv_point_xyz),
179 ("translation", peak_icv_point_xyz)]
180
181
182class peak_icv_calibration_parameters(ctypes.Structure):
183 _fields_ = [("intrinsic_parameters", peak_icv_intrinsic_parameters),
184 ("extrinsic_parameters", peak_icv_extrinsic_parameters)]
185
186
187class peak_icv_image_info(ctypes.Structure):
188 _fields_ = [
189 ("pixel_format", ctypes.c_uint),
190 ("size", peak_common_size),
191 ("buffer_size", ctypes.c_size_t),
192 ("buffer", ctypes.POINTER(ctypes.c_uint8))]
193
194
195class peak_icv_direction_vector(ctypes.Structure):
196 _fields_ = [("x", ctypes.c_double),
197 ("y", ctypes.c_double)]
198
199
200class peak_icv_reprojection_error(ctypes.Structure):
201 _fields_ = [
202 ("position", peak_icv_point_f),
203 ("direction", peak_icv_point_f),
204 ("length", ctypes.c_double),
205 ("reserved", ctypes.c_uint8 * 40)]
206
207
208peak_icv_binning_factor = peak_icv_point_u
209peak_icv_downsampling_factor = peak_icv_point_u
210
211
212class peak_icv_capture_information(ctypes.Structure):
213 _fields_ = [
214 ("binning_factor", peak_icv_binning_factor),
215 ("relative_timestamp", ctypes.c_uint64),
216 ("region_of_interest", peak_common_rectangle_u),
217 ("exposure_time", ctypes.c_double),
218 ("exposure_time_sequence", ctypes.c_double * 4),
219 ("gain", ctypes.c_double),
220 ("gain_sequence", ctypes.c_double * 4),
221 ("reserved", ctypes.c_uint8 * 24)
222 ]
223
224
225class peak_icv_color_correction_matrix(ctypes.Structure):
226 _fields_ = [
227 ("data_1d", ctypes.c_float * 9)
228 ]
229
230
232 _fields_ = [
233 ("mirror_left_right", ctypes.c_bool),
234 ("mirror_up_down", ctypes.c_bool),
235 ("rotation_angle", ctypes.c_uint32)
236 ]
237
238
239class peak_icv_region_handle(ctypes.c_void_p):
240 pass
241
242
243class peak_icv_polygon_handle(ctypes.c_void_p):
244 pass
245
246
248 pass
249
250
251class peak_icv_calibration_view_handle(ctypes.c_void_p):
252 pass
253
254
256 pass
257
258
259class peak_icv_point_cloud_handle(ctypes.c_void_p):
260 pass
261
262
263class peak_icv_image_handle(ctypes.c_void_p):
264 pass
265
266
267class peak_icv_undistortion_handle(ctypes.c_void_p):
268 pass
269
270
271class peak_icv_image_converter_handle(ctypes.c_void_p):
272 pass
273
274
276 pass
277
278
280 pass
281
282
283class peak_icv_downsampling_handle(ctypes.c_void_p):
284 pass
285
286
288 pass
289
290
291class peak_icv_hdr_handle(ctypes.c_void_p):
292 pass
293
294
295class peak_icv_tone_mapping_handle(ctypes.c_void_p):
296 pass
297
298
299def ctypes_objects_equal(obj1: object, obj2: object) -> bool:
300 """!
301 @brief
302 Compares two ctypes objects for equality by recursively comparing their fields.
303
304 Args:
305 obj1: First ctypes object.
306 obj2: Second ctypes object.
307
308 Returns:
309 True if all fields are equal, False otherwise.
310 """
311 if type(obj1) is not type(obj2):
312 return False # Objects must be of the same type
313
314 if not isinstance(obj1, ctypes.Structure):
315 return False
316
317 from typing import cast
318
319 obj1 = cast(ctypes.Structure, obj1)
320 obj2 = cast(ctypes.Structure, obj2)
321
322 for field_info in obj1._fields_:
323 field_name, field_type = field_info[:2]
324
325 val1 = getattr(obj1, field_name)
326 val2 = getattr(obj2, field_name)
327
328 if issubclass(field_type, ctypes.Structure): # Nested structure
329 if not ctypes_objects_equal(val1, val2):
330 return False
331 elif isinstance(val1, ctypes.Array): # Arrays need element-wise comparison
332 if len(val1) != len(val2) or any(v1 != v2 for v1, v2 in zip(val1, val2)):
333 return False
334 else: # Primitive types
335 if val1 != val2:
336 return False
337
338 return True
bool ctypes_objects_equal(object obj1, object obj2)
Compares two ctypes objects for equality by recursively comparing their fields.
Definition datatypes.py:299