-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get real distance from 16-bit value in depth image #2348
Comments
Each depth sensor has a depth scale value that translates pixels to meters. using namespace rs2;
pipeline p;
pipeline_profile profile = p.start();
device dev = profile.get_device();
depth_sensor ds = dev.query_sensors().front().as<depth_sensor>();
float scale = ds.get_depth_scale();
frameset fs = p.wait_for_frames();
depth_frame depth = fs.get_depth_frame();
uint16_t* data = (uint16_t*)depth.get_frame_data();
uint16_t pixel = data[0];
float meters = pixel * scale; The syntax may differ, but the APIs are very similar in other languages. |
[Realsense Customer Engineering Team Comment] The PNG image doesn't have the depth data info. You need to have the raw image (For example: use rs-convert tool to convert ros bag to raw) which data layout is according to the UVC spec for the depth stream. |
@dorodnic Will depth_scale change according to different scenes or distances between the camera and objects or it's a fixed number? |
It's a fixed number for sensor. With D400 advanced mode APIs you can adjust it a bit, to get better precision up close or further away, but that's a rather advanced use-case. |
[Realsense Customer Engineering Team Comment] |
@dorodnic @RealSense-Customer-Engineering Thanks for the anwer, much appreciated! |
[Realsense Customer Engineering Team Comment] Still need any support for this topic? |
@RealSense-Customer-Engineering Can you help solve this issue? https://github.com/IntelRealSense/librealsense/issues/2910 |
Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):
All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)
Issue Description
<I have depth images (png format), and I want to convert each pixel value (16bit) to real distance data (mm).
How can I convert it? Is there any specific formula? Thanks>
The text was updated successfully, but these errors were encountered: