Skip to content
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

Obtaining Actual Depth Values with the L515 #12904

Open
CCCCCCCT opened this issue May 7, 2024 · 9 comments
Open

Obtaining Actual Depth Values with the L515 #12904

CCCCCCCT opened this issue May 7, 2024 · 9 comments
Labels

Comments

@CCCCCCCT
Copy link

CCCCCCCT commented May 7, 2024

I currently have a depth map of 320240, and I also have an RGB image of 640480. How can I obtain the actual depth values in the depth map captured with my L515?

I can directly see the depth values using an application, but now I want to obtain the depth values from the captured images. I think this is a simple problem, but I've been stuck on it for a while. Please help me resolve this confusion. I would be very grateful.

2-3_Color

2-3_Depth

@MartyG-RealSense
Copy link
Collaborator

Hi @CCCCCCCT The RealSense SDK's rs-hello-realsense C++ example program demonstrates printing the actual real-world depth (distance) value in meters as a plain-text value.

https://github.com/IntelRealSense/librealsense/tree/master/examples/hello-realsense

If you have installed the RealSense SDK (librealsense) and its tools and examples then you can find a pre-built executable version of rs-hello-realsense at the following locations on your computer.

Windows
C: > Program Files (x86) > Intel RealSense SDK 2.0 >tools

Linux
/usr/local/bin

If you are using the Python language then #9939 provides an example of code for printing the distance value.

@MartyG-RealSense
Copy link
Collaborator

Hi @CCCCCCCT Do you require further assistance with this case, please? Thanks!

@CCCCCCCT
Copy link
Author

import pyrealsense2 as rs
import numpy as np

pipeline = rs.pipeline()

Start streaming

pipeline.start()

frames = pipeline.wait_for_frames()
depth = frames.get_depth_frame()

width = depth.get_width()
height = depth.get_height()

dist = depth.get_distance(int(width/2), int(height/2))

print(dist)

Stop streaming

pipeline.stop()

Hello! I have carefully tried it out, so the values I have here need to be multiplied by the default depth scale of the L515 to obtain the actual depth distance, right?

@MartyG-RealSense
Copy link
Collaborator

If you are using get_distance then you do not need to multiply the values by the depth scale, as get_distance() outputs the real-world distance in meters.

@MartyG-RealSense
Copy link
Collaborator

Hi @CCCCCCCT Do you require further assistance with this case, please? Thanks!

@CCCCCCCT
Copy link
Author

Hello, I can now import photos, but I still can't use python code to get the distance in the photo. Now I can use the L515 to directly turn on the camera to check the distance inside the camera, but this is not what I want.

Now I use opencv to check the depth of the pixel in the photo, but I think this is not right because my depth map is a png file.

Thank you so much for helping out.
image

@CCCCCCCT
Copy link
Author

I am thinking whether I should read the raw file, because my Depth file is png

@MartyG-RealSense
Copy link
Collaborator

Saving RealSense depth data to PNG causes a lot of the depth information to be lost, whilst a .raw file preserves the depth.

An example of Python code for exporting depth to .raw that was verified as correct by a RealSense team member is at IntelRealSense/realsense-ros#1312

For C++ users there is an example provided at #1485 (comment)

@CCCCCCCT
Copy link
Author

Thank you very much, I'll do it right away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants