1use crate::structs::*;
2use azure_kinect_sys::k4a::*;
3
4macro_rules! impl_conv_primitive_to_enum {
5 ($enum_type:ident, $primitive_type:ident) => {
6 impl From<$enum_type> for $primitive_type {
7 fn from(s: $enum_type) -> Self {
8 s as _
9 }
10 }
11
12 impl $enum_type {
13 #[allow(dead_code)]
14 pub(crate) fn from_primitive(s: $primitive_type) -> Self {
15 unsafe { std::mem::transmute(s) }
16 }
17 }
18 };
19}
20
21#[repr(u32)]
22#[derive(Clone, Copy, PartialEq, Debug)]
23#[doc = " Verbosity levels of debug messaging"]
24pub enum LogLevel {
25 #[doc = "< Most severe level of debug messaging."]
26 Critical = k4a_log_level_t_K4A_LOG_LEVEL_CRITICAL,
27 #[doc = "< 2nd most severe level of debug messaging."]
28 Error = k4a_log_level_t_K4A_LOG_LEVEL_ERROR,
29 #[doc = "< 3nd most severe level of debug messaging."]
30 Warning = k4a_log_level_t_K4A_LOG_LEVEL_WARNING,
31 #[doc = "< 2nd least severe level of debug messaging."]
32 Info = k4a_log_level_t_K4A_LOG_LEVEL_INFO,
33 #[doc = "< Least severe level of debug messaging."]
34 Trace = k4a_log_level_t_K4A_LOG_LEVEL_TRACE,
35 #[doc = "< No logging is performed"]
36 Off = k4a_log_level_t_K4A_LOG_LEVEL_OFF,
37}
38
39impl_conv_primitive_to_enum!(LogLevel, k4a_log_level_t);
40
41#[repr(u32)]
42#[derive(Clone, Copy, PartialEq, Debug)]
43pub enum DepthMode {
44 Off = k4a_depth_mode_t_K4A_DEPTH_MODE_OFF,
45 NFov2x2Binned = k4a_depth_mode_t_K4A_DEPTH_MODE_NFOV_2X2BINNED,
46 NFovUnbinned = k4a_depth_mode_t_K4A_DEPTH_MODE_NFOV_UNBINNED,
47 WFov2x2Binned = k4a_depth_mode_t_K4A_DEPTH_MODE_WFOV_2X2BINNED,
48 WFovUnbinned = k4a_depth_mode_t_K4A_DEPTH_MODE_WFOV_UNBINNED,
49 PassiveIr = k4a_depth_mode_t_K4A_DEPTH_MODE_PASSIVE_IR,
50}
51
52impl_conv_primitive_to_enum!(DepthMode, k4a_depth_mode_t);
53
54impl DepthMode {
55 pub fn get_dimension(&self) -> Dimension {
58 match self {
59 DepthMode::NFov2x2Binned => Dimension {
60 width: 320,
61 height: 288,
62 },
63 DepthMode::NFovUnbinned => Dimension {
64 width: 640,
65 height: 576,
66 },
67 DepthMode::WFov2x2Binned => Dimension {
68 width: 512,
69 height: 512,
70 },
71 DepthMode::WFovUnbinned => Dimension {
72 width: 1024,
73 height: 1024,
74 },
75 DepthMode::PassiveIr => Dimension {
76 width: 1024,
77 height: 1024,
78 },
79 _ => Dimension {
80 width: 0,
81 height: 0,
82 },
83 }
84 }
85
86 pub fn get_range(&self) -> Range<u16> {
89 match self {
90 DepthMode::NFov2x2Binned => Range::<u16> {
91 min: 500,
92 max: 5800,
93 },
94 DepthMode::NFovUnbinned => Range::<u16> {
95 min: 500,
96 max: 4000,
97 },
98 DepthMode::WFov2x2Binned => Range::<u16> {
99 min: 250,
100 max: 3000,
101 },
102 DepthMode::WFovUnbinned => Range::<u16> {
103 min: 250,
104 max: 2500,
105 },
106 _ => Range::<u16> { min: 0, max: 0 },
107 }
108 }
109
110 pub fn get_ir_level(&self) -> Range<u16> {
113 match self {
114 DepthMode::PassiveIr => Range::<u16> {
115 min: 250,
116 max: 3000,
117 },
118 DepthMode::Off => Range::<u16> { min: 0, max: 0 },
119 _ => Range::<u16> { min: 0, max: 1000 },
120 }
121 }
122}
123
124#[repr(u32)]
125#[derive(Clone, Copy, PartialEq, Debug)]
126pub enum ColorResolution {
127 Off = k4a_color_resolution_t_K4A_COLOR_RESOLUTION_OFF,
128 _720p = k4a_color_resolution_t_K4A_COLOR_RESOLUTION_720P,
129 _1080p = k4a_color_resolution_t_K4A_COLOR_RESOLUTION_1080P,
130 _1440p = k4a_color_resolution_t_K4A_COLOR_RESOLUTION_1440P,
131 _1536p = k4a_color_resolution_t_K4A_COLOR_RESOLUTION_1536P,
132 _2160p = k4a_color_resolution_t_K4A_COLOR_RESOLUTION_2160P,
133 _3072p = k4a_color_resolution_t_K4A_COLOR_RESOLUTION_3072P,
134}
135
136impl_conv_primitive_to_enum!(ColorResolution, k4a_color_resolution_t);
137
138impl ColorResolution {
139 pub fn get_dimension(&self) -> Dimension {
142 match self {
143 ColorResolution::_720p => Dimension {
144 width: 1280,
145 height: 720,
146 },
147 ColorResolution::_1080p => Dimension {
148 width: 1920,
149 height: 1080,
150 },
151 ColorResolution::_1440p => Dimension {
152 width: 2560,
153 height: 1440,
154 },
155 ColorResolution::_1536p => Dimension {
156 width: 2048,
157 height: 1536,
158 },
159 ColorResolution::_2160p => Dimension {
160 width: 3840,
161 height: 2160,
162 },
163 ColorResolution::_3072p => Dimension {
164 width: 4096,
165 height: 3072,
166 },
167 _ => Dimension {
168 width: 0,
169 height: 0,
170 },
171 }
172 }
173}
174
175#[repr(u32)]
176#[derive(Clone, Copy, PartialEq, Debug)]
177#[doc = " Image format type."]
178pub enum ImageFormat {
179 #[doc = " Color image type MJPG."]
180 MJPG = k4a_image_format_t_K4A_IMAGE_FORMAT_COLOR_MJPG,
181 #[doc = " Color image type NV12."]
182 NV12 = k4a_image_format_t_K4A_IMAGE_FORMAT_COLOR_NV12,
183 #[doc = " Color image type YUY2."]
184 YUY2 = k4a_image_format_t_K4A_IMAGE_FORMAT_COLOR_YUY2,
185 #[doc = " Color image type BGRA32."]
186 BGRA32 = k4a_image_format_t_K4A_IMAGE_FORMAT_COLOR_BGRA32,
187 #[doc = " Depth image type DEPTH16."]
188 Depth16 = k4a_image_format_t_K4A_IMAGE_FORMAT_DEPTH16,
189 #[doc = " Image type IR16."]
190 IR16 = k4a_image_format_t_K4A_IMAGE_FORMAT_IR16,
191 #[doc = " Single channel image type CUSTOM8."]
192 Custom8 = k4a_image_format_t_K4A_IMAGE_FORMAT_CUSTOM8,
193 #[doc = " Single channel image type CUSTOM16."]
194 Custom16 = k4a_image_format_t_K4A_IMAGE_FORMAT_CUSTOM16,
195 #[doc = " Custom image format."]
196 Custom = k4a_image_format_t_K4A_IMAGE_FORMAT_CUSTOM,
197}
198
199impl_conv_primitive_to_enum!(ImageFormat, k4a_image_format_t);
200
201#[repr(u32)]
202#[derive(Clone, Copy, PartialEq, Debug)]
203#[doc = " Transformation interpolation type."]
204pub enum TransformationInterpolationType {
205 #[doc = "< Nearest neighbor interpolation"]
206 Nearest = k4a_transformation_interpolation_type_t_K4A_TRANSFORMATION_INTERPOLATION_TYPE_NEAREST,
207 #[doc = "< Linear interpolation"]
208 Linear = k4a_transformation_interpolation_type_t_K4A_TRANSFORMATION_INTERPOLATION_TYPE_LINEAR,
209}
210
211impl_conv_primitive_to_enum!(
212 TransformationInterpolationType,
213 k4a_transformation_interpolation_type_t
214);
215
216#[repr(u32)]
217#[derive(Clone, Copy, PartialEq, Debug)]
218pub enum Fps {
219 _5fps = k4a_fps_t_K4A_FRAMES_PER_SECOND_5,
220 _15fps = k4a_fps_t_K4A_FRAMES_PER_SECOND_15,
221 _30fps = k4a_fps_t_K4A_FRAMES_PER_SECOND_30,
222}
223
224impl_conv_primitive_to_enum!(Fps, k4a_fps_t);
225
226impl Fps {
227 pub fn get_u32(&self) -> u32 {
228 match self {
229 Fps::_5fps => 5,
230 Fps::_15fps => 15,
231 Fps::_30fps => 30,
232 }
233 }
234}
235
236#[repr(u32)]
237#[derive(Clone, Copy, PartialEq, Debug)]
238#[doc = " Color sensor control commands"]
239pub enum ColorControlCommand {
240 #[doc = " Exposure time setting."]
241 ExposureTimeAbsolute = k4a_color_control_command_t_K4A_COLOR_CONTROL_EXPOSURE_TIME_ABSOLUTE,
242 #[doc = " Exposure or Framerate priority setting."]
243 AutoExposurePriority = k4a_color_control_command_t_K4A_COLOR_CONTROL_AUTO_EXPOSURE_PRIORITY,
244 #[doc = " Brightness setting."]
245 Brightness = k4a_color_control_command_t_K4A_COLOR_CONTROL_BRIGHTNESS,
246 #[doc = " Contrast setting."]
247 Contrast = k4a_color_control_command_t_K4A_COLOR_CONTROL_CONTRAST,
248 #[doc = " Saturation setting."]
249 Saturation = k4a_color_control_command_t_K4A_COLOR_CONTROL_SATURATION,
250 #[doc = " Sharpness setting."]
251 Sharpness = k4a_color_control_command_t_K4A_COLOR_CONTROL_SHARPNESS,
252 #[doc = " White balance setting."]
253 WhiteBalance = k4a_color_control_command_t_K4A_COLOR_CONTROL_WHITEBALANCE,
254 #[doc = " Backlight compensation setting."]
255 BacklightCompensation = k4a_color_control_command_t_K4A_COLOR_CONTROL_BACKLIGHT_COMPENSATION,
256 #[doc = " Gain setting."]
257 Gain = k4a_color_control_command_t_K4A_COLOR_CONTROL_GAIN,
258 #[doc = " Powerline frequency setting."]
259 PowerlineFrequency = k4a_color_control_command_t_K4A_COLOR_CONTROL_POWERLINE_FREQUENCY,
260}
261
262impl_conv_primitive_to_enum!(ColorControlCommand, k4a_color_control_command_t);
263
264#[repr(u32)]
265#[derive(Clone, Copy, PartialEq, Debug)]
266#[doc = " Calibration types."]
267pub enum ColorControlMode {
268 #[doc = "< set the associated k4a_color_control_command_t to auto"]
269 Auto = k4a_color_control_mode_t_K4A_COLOR_CONTROL_MODE_AUTO,
270 #[doc = "< set the associated k4a_color_control_command_t to manual"]
271 Manual = k4a_color_control_mode_t_K4A_COLOR_CONTROL_MODE_MANUAL,
272}
273
274impl_conv_primitive_to_enum!(ColorControlMode, k4a_color_control_mode_t);
275
276#[repr(u32)]
277#[derive(Clone, Copy, PartialEq, Debug)]
278#[doc = " Synchronization mode when connecting two or more devices together."]
279pub enum WiredSyncMode {
280 #[doc = "< Neither 'Sync In' or 'Sync Out' connections are used."]
281 Standalone = k4a_wired_sync_mode_t_K4A_WIRED_SYNC_MODE_STANDALONE,
282 #[doc = "< The 'Sync Out' jack is enabled and synchronization data it driven out the connected wire."]
283 Master = k4a_wired_sync_mode_t_K4A_WIRED_SYNC_MODE_MASTER,
284 #[doc = "< The 'Sync In' jack is used for synchronization and 'Sync Out' is driven for the next device in the chain."]
285 Subordinate = k4a_wired_sync_mode_t_K4A_WIRED_SYNC_MODE_SUBORDINATE,
286}
287
288impl_conv_primitive_to_enum!(WiredSyncMode, k4a_wired_sync_mode_t);
289
290#[repr(i32)]
291#[derive(Clone, Copy, PartialEq, Debug)]
292#[doc = " Calibration types."]
293pub enum CalibrationType {
294 #[doc = "< Calibration type is unknown"]
295 Unknown = k4a_calibration_type_t_K4A_CALIBRATION_TYPE_UNKNOWN,
296 #[doc = "< Depth sensor"]
297 Depth = k4a_calibration_type_t_K4A_CALIBRATION_TYPE_DEPTH,
298 #[doc = "< Color sensor"]
299 Color = k4a_calibration_type_t_K4A_CALIBRATION_TYPE_COLOR,
300 #[doc = "< Gyroscope sensor"]
301 Gyro = k4a_calibration_type_t_K4A_CALIBRATION_TYPE_GYRO,
302 #[doc = "< Accelerometer sensor"]
303 Accel = k4a_calibration_type_t_K4A_CALIBRATION_TYPE_ACCEL,
304}
305
306impl_conv_primitive_to_enum!(CalibrationType, k4a_calibration_type_t);
307
308#[repr(u32)]
309#[derive(Clone, Copy, PartialEq, Debug)]
310#[doc = " Calibration model type."]
311pub enum CalibrationModelType {
312 #[doc = "< Calibration model is unknown"]
313 Unknown = k4a_calibration_model_type_t_K4A_CALIBRATION_LENS_DISTORTION_MODEL_UNKNOWN,
314 #[doc = "< Deprecated (not supported). Calibration model is Theta (arctan)."]
315 Theta = k4a_calibration_model_type_t_K4A_CALIBRATION_LENS_DISTORTION_MODEL_THETA,
316 #[doc = "< Deprecated (not supported). Calibration model is Polynomial 3K."]
317 Polynomial3K = k4a_calibration_model_type_t_K4A_CALIBRATION_LENS_DISTORTION_MODEL_POLYNOMIAL_3K,
318 #[doc = "< Deprecated (only supported early internal devices). Calibration model is Rational 6KT."]
319 Rational6KT = k4a_calibration_model_type_t_K4A_CALIBRATION_LENS_DISTORTION_MODEL_RATIONAL_6KT,
320 #[doc = "< Calibration model is Brown Conrady (compatible with OpenCV)"]
321 BrownConrady = k4a_calibration_model_type_t_K4A_CALIBRATION_LENS_DISTORTION_MODEL_BROWN_CONRADY,
322}
323
324impl_conv_primitive_to_enum!(CalibrationModelType, k4a_calibration_model_type_t);
325
326#[repr(u32)]
327#[derive(Clone, Copy, PartialEq, Debug)]
328#[doc = " Firmware build type."]
329pub enum FirmwareBuildType {
330 #[doc = "< Production firmware."]
331 Release = k4a_firmware_build_t_K4A_FIRMWARE_BUILD_RELEASE,
332 #[doc = "< Pre-production firmware."]
333 Debug = k4a_firmware_build_t_K4A_FIRMWARE_BUILD_DEBUG,
334}
335
336impl_conv_primitive_to_enum!(FirmwareBuildType, k4a_firmware_build_t);
337
338#[repr(u32)]
339#[derive(Clone, Copy, PartialEq, Debug)]
340#[doc = " Firmware signature type."]
341pub enum FirmwareSignatureType {
342 #[doc = "< Microsoft signed firmware."]
343 Microsoft = k4a_firmware_signature_t_K4A_FIRMWARE_SIGNATURE_MSFT,
344 #[doc = "< Test signed firmware."]
345 Test = k4a_firmware_signature_t_K4A_FIRMWARE_SIGNATURE_TEST,
346 #[doc = "< Unsigned firmware."]
347 Unsigned = k4a_firmware_signature_t_K4A_FIRMWARE_SIGNATURE_UNSIGNED,
348}
349
350impl_conv_primitive_to_enum!(FirmwareSignatureType, k4a_firmware_signature_t);