depth frame value == the real distance?
My camera is realsense D435, below is my code:
Doesn't the depthwrame pixel value represent distance?
-
Hello, get_distance(x, y) provides the real-world distance in meters.
Another method of obtaining real-world distance is to use the uint16_t value, as you mentioned. However, this is the raw pixel depth value. To convert it to real-world meters, you need to multiply the uint16_t value by the depth scale of the RealSense camera. For most RealSense 400 Series models except D405, the default scale value is 0.001. This is the scale that the D435 model uses.
For example, if the uint16_t depth value was 6500 then you would do 6500 x 0.001 = 6.5 (real-world meters).
-
Are the X,Y coordinate values for depth_image[x,y] the same as the X,Y values used by get_distance?
I would recommend using either one method of the other, not both at the same time. So if get_distance reliably and consistently returns accurate distance values then use only that.
Saving depth to .png causes most of the depth information to be lost, meaning that the image may look like a depth map but you could not retrieve accurate distances from the image. A .raw image preserves the depth values.
-
Yes, the above two methods use the same x and y, and the code is as follows.
def get_distance(event, x, y, flags, param):if event == cv2.EVENT_RBUTTONDOWN:scale = profile.get_device().first_depth_sensor().get_depth_scale()print("depth_image[x, y] * scale:",depth_image[x, y] * scale)distance = depth_frame.get_distance(x, y)print(f"get_distance at x, y): {distance} meters")print("*"*100)For me, the get-distance method seems more accurate, but it can only obtain the distance information of a certain point. If we iterate through each pixel, it will obviously take a lot of time. Is there a method similar to get-distance to quickly obtain the distances of all pixels in an image?
If I use the get_travel method to obtain distance, does it mean that my depth map is unnecessary? -
You do not need to generate a visible depth image on-screen in order to retrieve depth values. You can do it simply with get_distance, like the RealSense SDK's official rs-hello-realsense example program that uses get_distance to print the depth value at the center of the camera's view as a plain-text number with no graphics.
Any method which obtains the depths of all the pixels will be processing-intensive and slower than retrieving the depth of a single coordinate.
Please sign in to leave a comment.
Comments
6 comments