realsense_rust/kind/frame_metadata.rs
1//! Enumeration of frame-specific metadata
2
3use num_derive::{FromPrimitive, ToPrimitive};
4use realsense_sys as sys;
5
6/// A type describing the different metadata keys used to access frame metadata.
7///
8/// Each key corresponds to a particular type of frame metadata. The librealsense2 C-API refers to
9/// these as `rs2_frame_metadata_value`; however these are clearly keys to metadata values.
10///
11#[repr(i32)]
12#[derive(FromPrimitive, ToPrimitive, Debug, Clone, Copy, PartialEq, Eq, Hash)]
13pub enum Rs2FrameMetadata {
14 /// A sequential index managed per-stream, counting up from the first frame at zero.
15 FrameCounter = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_FRAME_COUNTER as i32,
16 /// Timestamp set by device clock when data is read out and transmission commences.
17 ///
18 /// Units are microseconds (usec)
19 FrameTimestamp = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_FRAME_TIMESTAMP as i32,
20 /// Timestamp for the middle of the sensor's exposure during frame capture.
21 ///
22 /// This value is calculated by the device (not host). Units are microseconds (usec)
23 SensorTimestamp = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_SENSOR_TIMESTAMP as i32,
24 /// The exposure duration used by the sensor when this frame was captured.
25 ///
26 /// When auto-exposure (AE) is turned on, this value is controlled by the device's firmware.
27 /// Units are microseconds (usec).
28 ActualExposure = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_ACTUAL_EXPOSURE as i32,
29 /// The sensor's gain level during frame capture.
30 ///
31 /// This value is a relative integer value, and may not correspond to a physical quantity. When
32 /// auto-exposure (AE) is turned on, this value is controlled by the device's firmware.
33 GainLevel = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_GAIN_LEVEL as i32,
34 /// Indicates if auto-exposure (AE) was turned on during frame capture.
35 ///
36 /// A value of zero corresponds to AE being off, otherwise it is on.
37 AutoExposure = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_AUTO_EXPOSURE as i32,
38 /// The white balance setting as a color temperature during frame capture.
39 ///
40 /// Units are Kelvin degrees.
41 WhiteBalance = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_WHITE_BALANCE as i32,
42 /// The timestamp at which the frame arrived on the host machine.
43 ///
44 /// This timestamp, unlike the others, is relative to the system clock on host.
45 TimeOfArrival = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_TIME_OF_ARRIVAL as i32,
46 /// Temperature of the device during frame capture.
47 ///
48 /// Units are Celsius degrees.
49 Temperature = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_TEMPERATURE as i32,
50 /// Timestamp of the uvc driver.
51 ///
52 /// Units are microseconds (usec)
53 BackendTimestamp = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_BACKEND_TIMESTAMP as i32,
54 /// The actual framerate of the stream at the point of frame capture.
55 ///
56 /// This may be different than the framerate returned by the stream profile data (which is the
57 /// framerate you configured). This may differ as a result of frame drops in the firmware, or
58 /// measurement noise (e.g. you get 29.99 FPS when you asked for 30 FPS).
59 ActualFps = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_ACTUAL_FPS as i32,
60 /// Relative measure of laser power during frame capture.
61 ///
62 /// Laser power is a relative measure between values of 0 and 360
63 FrameLaserPower = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_FRAME_LASER_POWER as i32,
64 /// The laser power mode used at time of frame capture.
65 ///
66 /// Zero corresponds to laser power being switched off, and one for laser power being turned
67 /// on.
68 ///
69 /// This variant was deprecated by librealsense2, prefer using
70 /// `Rs2FrameMetadata::FrameEmitterMode` instead.
71 FrameLaserPowerMode =
72 sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_FRAME_LASER_POWER_MODE as i32,
73 /// Exposure priority
74 ExposurePriority = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_EXPOSURE_PRIORITY as i32,
75 /// Left region of interest for the auto-exposure algorithm.
76 ExposureRoiLeft = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_EXPOSURE_ROI_LEFT as i32,
77 /// Right region of interest for the auto-exposure algorithm.
78 ExposureRoiRight = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_EXPOSURE_ROI_RIGHT as i32,
79 /// Top region of interest for the auto-exposure algorithm.
80 ExposureRoiTop = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_EXPOSURE_ROI_TOP as i32,
81 /// Bottom region of interest for the auto-exposure algorithm.
82 ExposureRoiBottom = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_EXPOSURE_ROI_BOTTOM as i32,
83 /// Brightness of the color image at time of frame capture.
84 Brightness = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_BRIGHTNESS as i32,
85 /// Contrast of the color image at time of frame capture.
86 Contrast = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_CONTRAST as i32,
87 /// Saturation of the color image at time of frame capture.
88 Saturation = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_SATURATION as i32,
89 /// Sharpness of the color image at time of frame capture.
90 Sharpness = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_SHARPNESS as i32,
91 /// Indicator for whether auto-white-balance (AWB) was turned on during frame capture.
92 ///
93 /// Zero corresponds to automatic mode being switched off, otherwise it is on.
94 AutoWhiteBalanceTemperature =
95 sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_AUTO_WHITE_BALANCE_TEMPERATURE as i32,
96 /// Indicator for whether backlight compensation was enabled on a color image.
97 ///
98 /// Zero corresponds to backlight compensation being switched off, otherwise it is on.
99 BacklightCompensation =
100 sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_BACKLIGHT_COMPENSATION as i32,
101 /// Hue of the color image at time of frame capture.
102 Hue = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_HUE as i32,
103 /// Gamma of the color image at time of frame capture.
104 Gamma = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_GAMMA as i32,
105 /// White balance of the color image at time of frame capture.
106 ManualWhiteBalance =
107 sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_MANUAL_WHITE_BALANCE as i32,
108 /// Power line frequency mode for anti-flickering.
109 ///
110 /// Values can be Off, 50Hz, 60Hz, and Auto.
111 PowerLineFrequency =
112 sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_POWER_LINE_FREQUENCY as i32,
113 /// Indicator for whether lowlight compensation was enabled on the color image.
114 ///
115 /// Zero corresponds to lowlight compensation being switched off, otherwise it is on.
116 LowLightCompensation =
117 sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_LOW_LIGHT_COMPENSATION as i32,
118 /// The frame emitter mode used at the time of frame capture.
119 ///
120 /// Possible values are:
121 ///
122 /// * 0 - all emitters disabled.
123 /// * 1 - laser enabled.
124 /// * 2 - auto laser enabled (opt).
125 /// * 3 - LED enabled (opt).
126 ///
127 FrameEmitterMode = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_FRAME_EMITTER_MODE as i32,
128 /// Relative power of the LED emitter during frame capture.
129 ///
130 /// This is a relative measure between values of 0 and 360.
131 FrameLedPower = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_FRAME_LED_POWER as i32,
132 /// The number of transmitted payload bytes for the frame, not including metadata
133 RawFrameSize = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_RAW_FRAME_SIZE as i32,
134 /// GPIO input data
135 GpioInputData = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_GPIO_INPUT_DATA as i32,
136 /// Sub-preset identifier
137 SequenceName = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_SEQUENCE_NAME as i32,
138 /// Sub-preset sequence identifier
139 SequenceIdentifier = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_SEQUENCE_ID as i32,
140 /// Sub-preset sequence size
141 SequenceSize = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_SEQUENCE_SIZE as i32,
142 /// Frame trigger type
143 Trigger = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_TRIGGER as i32,
144 /// Preset id, used in MIPI SKU Metadata
145 Preset = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_PRESET as i32,
146 /// Frame input width in pixels, used as safety attribute
147 InputWidth = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_INPUT_WIDTH as i32,
148 /// Frame input height in pixels, used as safety attribute
149 InputHeight = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_INPUT_HEIGHT as i32,
150 /// Sub-preset information
151 SubPresetInfo = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_SUB_PRESET_INFO as i32,
152 /// FW-controlled frame counter to be using in Calibration scenarios
153 CalibInfo = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_CALIB_INFO as i32,
154 /// CRC checksum of the Metadata
155 Crc = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_CRC as i32,
156 // Not included since this just tells us the total number of metadata fields
157 //
158 // Count = sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_COUNT,
159}
160
161#[cfg(test)]
162mod tests {
163 use super::*;
164 use num_traits::FromPrimitive;
165
166 #[test]
167 fn all_variants_exist() {
168 for i in 0..sys::rs2_frame_metadata_value_RS2_FRAME_METADATA_COUNT as i32 {
169 assert!(
170 Rs2FrameMetadata::from_i32(i).is_some(),
171 "Rs2FrameMetadata variant for ordinal {} does not exist.",
172 i,
173 );
174 }
175 }
176}