unable to get depth_scale
Hi,
I'm working with a D435 depth camera using the C++ API inside an openFrameworks project.
Everything is working fine, I can grab the color picture, and also the depth frame and make post-processing.
I can also get the field of view using the exact same code from the example here but when it comes to get the depth_sclale (using the get_depth_scale method on the sensor) my compiler complaints about the fact that
error: 'class rs2::sensor' has no member named 'get_depth_scale'
273 | auto depthScale = sensor.get_depth_scale();
The code I'm using is the following
selection = pipe.start( config );
auto sensorAuto = selection.get_device().first<rs2::depth_sensor>();
auto depthScale = sensor.get_depth_scale();
I'm using the 2.50 C++ API.
what am I doing wrong?
hank you for your support
-
Hi Nicola Ariutti It looks as though if you are defining the depth sensor as sensorAuto then that name should be used to get the depth scale instead of 'sensor':
auto depthScale = sensorAuto.get_depth_scale();
Almost all 400 Series camera models have a default depth unit scale of 0.001 (the D405's is 0.01) so whilst you can retrieve the depth scale in real-time from the camera, the scale does not change unless altered deliberately by the program or a user input and so it can be easier simply to use a fixed numeric value of 0.001 for the scale.
-
thank you MartyX Grover for your quick reply,
and sorry for this trivial mistake of distraction.
Now that my code has been fixed, I don't have the error anymore and, as you pointed out, I get a value of 0.001.
If I understood correctly it means that every unit in the Z16 depth frame I get from the sensor, corresponds to 0.001 meters, isn't it?
So, when it cames to set the min and max thresholds for the depth threshold filter, I have to think in terms of depth unit (and not in terms of meters), is it correct?
What are the extremes of the scale within which these values can vary?
Thank you so much! -
The raw pixel depth value (uint16_t) has a range of 0-65535 and the real-world distance in meters is obtained by multiplying the pixel depth value by the depth unit scale value of the camera. So on a 400 Series camera, 65535 x 0.001 gives a real-world maximum depth distance of 65.535 meters.
In real-world conditions the D435 has a min-max depth range of between 0.1 meters (10 cm) and 10 meters. Whilst you could set the threshold maximum to a further distance, the camera will not be able to read depth information at that greater distance beyond 10 meters.
Please sign in to leave a comment.
Comments
3 comments