Access Pointcloud data like in the SDK

Dear community,

I need to access a point in the pointcloud, of which I know the pixel coordinates of the picture of the left camera. In the SDK it seems to be a really easy task like it is described here: https://www.stereolabs.com/docs/depth-sensing/using-depth/

point_cloud = sl.Mat()
zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA)
# Get the 3D point cloud values for pixel (i,j)
point3D = point_cloud.get_value(i,j)
x = point3D[0]
y = point3D[1]
z = point3D[2]
color = point3D[3]

The rostopic /zed2i/zed_node/point_cloud/cloud_registered is a PointCloud2 message which is an array of the points. How is there the procedure to access the points by the pixel coordinates?

Thanks in advance and regards
Florian

I believe you are looking for this?

x = point3D[i,j,0]
y = point3D[i,j,1]
z = point3D[i,j,2]

Thanks for your reply! I just found out that the problem I faced has nothing to do with ROS2 wrapper of the ZED2i Camera. To implement my algorithms I used a dataset, in which they also used an ZED-Camera. Unfortunately they didn’t output it the same way like the ROS2 wrapper is doing. They just outputed a point cloud which was not structured and I assumed the ROS2 wrapper outputs it the same way without checking it. With the output of the ROS2 wrapper it is easy to access the correct point cloud points like you mentioned @Flocker , because the point cloud has the same shape as the image.