How to calculate distance of objects from depth data in MATLAB?
Hi~, I am using matlab and D415, and have gotten the depth data by following the matlab example. However, I didn't find the example for calculating distance of objects from the depth data.
I found that in a python example librealsense/distance_to_object.ipynb at jupyter · IntelRealSense/librealsense · GitHub, there is a way to calculate distance:
depth = np.asanyarray(aligned_depth_frame.get_data())
# Crop depth data:
depth = depth[xmin_depth:xmax_depth,ymin_depth:ymax_depth].astype(float)
# Get data scale from the device and convert to meters
depth_scale = profile.get_device().first_depth_sensor().get_depth_scale()
depth = depth * depth_scale# depth is the distance of the object
Obviously, the code above for python does not work in matlab.
So, how to calculate distance of objects in matlab?
Many thanks.
-
I hope that the information in the link below will be helpful to you.
https://github.com/IntelRealSense/librealsense/issues/6612#issuecomment-645229665
Please sign in to leave a comment.
Comments
3 comments