3

Is there a way to obtain a mapping from a point in the pointcloud obtained from the Realsense to a pixel in the depth map? The pointcloud is obtained from the depth map, but pixels without valid depth data are left out. The Realsense API only provides a routine to map points to RGB pixels.

We use librealsense and the Realsense ROS driver.

Niccer
  • 31
  • 3

1 Answers1

2

You can use rs2_project_point_to_pixel to project from 3D space to the 2D plane. You need the intrinsics of the stream the point cloud is aligned to (ie, depth if normal, colour if aligned). It will only work for points with nonzero depth though.

If the function isn't available in the ROS wrapper it should be easy enough to translate, it's just arithmetic.

jb455
  • 100
  • 1
  • 7
  • Thanks! That solves it, but it's computationally expensive. – Could I rely on a certain ordering of points/generation rule in the pointcloud? Like: Go through the depth map row-wise, and for every valid depth value increase the index into the pointcloud by 1? – Niccer Nov 20 '19 at 17:58
  • Normally the point cloud will be in the same order as the depth image it came from so that should work also. I think the point cloud will include zero points when there is no valid depth so you shouldn't need to skip over any. Check that your point cloud array is the same size as the depth image resolution. – jb455 Nov 22 '19 at 09:39