File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,6 +69,16 @@ pub struct DepthFrame {
6969}
7070impl_video_frame ! ( DepthFrame ) ;
7171
72+ impl DepthFrame {
73+ /// Get the scale (pixel value * scale = distance in millimeters) of the depth frame
74+ pub fn depth_scale ( & self ) -> f32 {
75+ // Unwrap is safe here because internal pointer is guaranteed to be valid and a depth frame
76+ // SDK only returns error for this function if pointer is NULL or not a depth frame
77+ // Ref: https://github.com/orbbec/OrbbecSDK_v2/blob/815ae047cc977a1f7edd2b97b69ff6cd29f510b3/src/impl/Frame.cpp#L198
78+ self . inner . get_depth_scale ( ) . unwrap ( )
79+ }
80+ }
81+
7282/// Point Cloud frame
7383pub struct PointCloudFrame {
7484 inner : OBFrame ,
Original file line number Diff line number Diff line change @@ -150,4 +150,16 @@ impl OBFrame {
150150
151151 Ok ( scale)
152152 }
153+
154+ /// Get the depth frame scale.
155+ /// Only valid for depth frames.
156+ pub fn get_depth_scale ( & self ) -> Result < f32 , OBError > {
157+ let mut err_ptr = std:: ptr:: null_mut ( ) ;
158+
159+ let scale = unsafe { orb:: ob_depth_frame_get_value_scale ( self . inner , & mut err_ptr) } ;
160+
161+ OBError :: consume ( err_ptr) ?;
162+
163+ Ok ( scale)
164+ }
153165}
You can’t perform that action at this time.
0 commit comments