IDS peak ICV v1.1.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_icv_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_icv_interval_f(ctypes.Structure):
44 _fields_ = [("minimum", ctypes.c_float),
45 ("maximum", ctypes.c_float)]
46
47
48class peak_common_size(ctypes.Structure):
49 _fields_ = [("width", ctypes.c_uint32),
50 ("height", ctypes.c_uint32)]
51
52
53class peak_common_size_f(ctypes.Structure):
54 _fields_ = [("width", ctypes.c_float),
55 ("height", ctypes.c_float)]
56
57
58class peak_icv_drawing_options(ctypes.Structure):
59 _fields_ = [("color", ctypes.c_uint64),
60 ("opacity", ctypes.c_uint32),
61 ("line_width", ctypes.c_size_t)]
62
63
64class peak_icv_point(ctypes.Structure):
65 _fields_ = [("x", ctypes.c_int32),
66 ("y", ctypes.c_int32)]
67
68
69class peak_icv_point_u(ctypes.Structure):
70 _fields_ = [("x", ctypes.c_uint32),
71 ("y", ctypes.c_uint32)]
72
73
74class peak_icv_point_f(ctypes.Structure):
75 _fields_ = [("x", ctypes.c_float),
76 ("y", ctypes.c_float)]
77
78
79class peak_icv_point_xyz(ctypes.Structure):
80 _fields_ = [("x", ctypes.c_float),
81 ("y", ctypes.c_float),
82 ("z", ctypes.c_float),
83 ("_", ctypes.c_float)]
84
85
86class peak_icv_point_xyzi(ctypes.Structure):
87 _fields_ = [("x", ctypes.c_float),
88 ("y", ctypes.c_float),
89 ("z", ctypes.c_float),
90 ("i", ctypes.c_uint16)]
91
92
93class peak_common_rectangle(ctypes.Structure):
94 _fields_ = [("x", ctypes.c_int32),
95 ("y", ctypes.c_int32),
96 ("width", ctypes.c_uint32),
97 ("height", ctypes.c_uint32)]
98
99
100class peak_common_rectangle_u(ctypes.Structure):
101 _fields_ = [("x", ctypes.c_uint32),
102 ("y", ctypes.c_uint32),
103 ("width", ctypes.c_uint32),
104 ("height", ctypes.c_uint32)]
105
106
107class peak_common_rectangle_f(ctypes.Structure):
108 _fields_ = [("x", ctypes.c_float),
109 ("y", ctypes.c_float),
110 ("width", ctypes.c_float),
111 ("height", ctypes.c_float)]
112
113
114class peak_common_version(ctypes.Structure):
115 _fields_ = [("major", ctypes.c_uint32),
116 ("minor", ctypes.c_uint32),
117 ("patch", ctypes.c_uint32),
118 ("revision", ctypes.c_uint32)]
119
120
121class peak_icv_prism_distortion(ctypes.Structure):
122 _fields_ = [("coefficients", ctypes.c_double * 4)]
123
124
125class peak_icv_radial_distortion(ctypes.Structure):
126 _fields_ = [("coefficients", ctypes.c_double * 6)]
127
128
129class peak_icv_tangential_distortion(ctypes.Structure):
130 _fields_ = [("coefficients", ctypes.c_double * 2)]
131
132
133class peak_icv_tilt_distortion(ctypes.Structure):
134 _fields_ = [("coefficients", ctypes.c_double * 2)]
135
136
137class peak_icv_distortion_coefficients(ctypes.Structure):
138 _fields_ = [("radial_distortion", peak_icv_radial_distortion),
139 ("tangential_distortion", peak_icv_tangential_distortion),
140 ("prism_distortion", peak_icv_prism_distortion),
141 ("tilt_distortion", peak_icv_tilt_distortion)]
142
143
144class peak_icv_coordinate_system(ctypes.Structure):
145 _fields_ = [("origin", peak_icv_point_f),
146 ("x_axis", peak_icv_point_f),
147 ("y_axis", peak_icv_point_f),
148 ("z_axis", peak_icv_point_f)]
149
150
151class peak_icv_header(ctypes.Structure):
152 _fields_ = [("marker", ctypes.c_uint32),
153 ("type", ctypes.c_uint32),
154 ("flags", ctypes.c_uint32),
155 ("version", peak_common_version),
156 ("crc", ctypes.c_uint32)]
157
158
159peak_icv_binning = peak_icv_point_u
160
161
162class peak_icv_intrinsic_parameters(ctypes.Structure):
163 _fields_ = [
164 ("image_size", peak_common_size),
165 ("binning_factor", peak_icv_binning),
166 ("distortion_coefficients", peak_icv_distortion_coefficients),
167 ("focal_length_pixel_size_ratio", peak_icv_point_f),
168 ("principle_point", peak_icv_point_f)]
169
170
171class peak_icv_extrinsic_parameters(ctypes.Structure):
172 _fields_ = [("rotation", peak_icv_point_xyz),
173 ("translation", peak_icv_point_xyz)]
174
175
176class peak_icv_calibration_parameters(ctypes.Structure):
177 _fields_ = [("intrinsic_parameters", peak_icv_intrinsic_parameters),
178 ("extrinsic_parameters", peak_icv_extrinsic_parameters)]
179
180
181class peak_icv_image_info(ctypes.Structure):
182 _fields_ = [
183 ("pixel_format", ctypes.c_int),
184 ("size", peak_common_size),
185 ("buffer_size", ctypes.c_size_t),
186 ("buffer", ctypes.POINTER(ctypes.c_uint8))]
187
188
189class peak_icv_direction_vector(ctypes.Structure):
190 _fields_ = [("x", ctypes.c_double),
191 ("y", ctypes.c_double)]
192
193
194class peak_icv_reprojection_error(ctypes.Structure):
195 _fields_ = [
196 ("position", peak_icv_point_f),
197 ("direction", peak_icv_point_f),
198 ("length", ctypes.c_double),
199 ("reserved", ctypes.c_uint8 * 40)]
200
201
202peak_icv_binning_factor = peak_icv_point_u
203peak_icv_downsampling_factor = peak_icv_point_u
204
205
206class peak_icv_capture_information(ctypes.Structure):
207 _fields_ = [
208 ("binning_factor", peak_icv_binning_factor),
209 ("relative_timestamp", ctypes.c_uint64),
210 ("region_of_interest", peak_common_rectangle_u),
211 ("reserved", ctypes.c_uint8 * 104)
212 ]
213
214
215class peak_icv_color_correction_matrix(ctypes.Structure):
216 _fields_ = [
217 ("data_1d", ctypes.c_float * 9)
218 ]
219
220
222 _fields_ = [
223 ("mirror_left_right", ctypes.c_bool),
224 ("mirror_up_down", ctypes.c_bool),
225 ("rotation_angle", ctypes.c_uint32)
226 ]
227
228
229class peak_icv_region_handle(ctypes.c_void_p):
230 pass
231
232
233class peak_icv_polygon_handle(ctypes.c_void_p):
234 pass
235
236
238 pass
239
240
241class peak_icv_calibration_view_handle(ctypes.c_void_p):
242 pass
243
244
246 pass
247
248
249class peak_icv_point_cloud_handle(ctypes.c_void_p):
250 pass
251
252
253class peak_icv_image_handle(ctypes.c_void_p):
254 pass
255
256
257class peak_icv_undistortion_handle(ctypes.c_void_p):
258 pass
259
260
261class peak_icv_image_converter_handle(ctypes.c_void_p):
262 pass
263
264
266 pass
267
268
270 pass
271
272
273class peak_icv_downsampling_handle(ctypes.c_void_p):
274 pass
275
276
278 pass
279
280
281def ctypes_objects_equal(obj1: object, obj2: object) -> bool:
282 """!
283 @brief
284 Compares two ctypes objects for equality by recursively comparing their fields.
285
286 Args:
287 obj1: First ctypes object.
288 obj2: Second ctypes object.
289
290 Returns:
291 True if all fields are equal, False otherwise.
292 """
293 if type(obj1) is not type(obj2):
294 return False # Objects must be of the same type
295
296 if not isinstance(obj1, ctypes.Structure):
297 return False
298
299 from typing import cast
300
301 obj1 = cast(ctypes.Structure, obj1)
302 obj2 = cast(ctypes.Structure, obj2)
303
304 for field_info in obj1._fields_:
305 field_name, field_type = field_info[:2]
306
307 val1 = getattr(obj1, field_name)
308 val2 = getattr(obj2, field_name)
309
310 if issubclass(field_type, ctypes.Structure): # Nested structure
311 if not ctypes_objects_equal(val1, val2):
312 return False
313 elif isinstance(val1, ctypes.Array): # Arrays need element-wise comparison
314 if len(val1) != len(val2) or any(v1 != v2 for v1, v2 in zip(val1, val2)):
315 return False
316 else: # Primitive types
317 if val1 != val2:
318 return False
319
320 return True
bool ctypes_objects_equal(object obj1, object obj2)
Compares two ctypes objects for equality by recursively comparing their fields.
Definition datatypes.py:281