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

Are verts data generate from rs.pointcloud the same from using rs2_deproject_pixel_to_point? #13529

Open
ysj2009 opened this issue Nov 20, 2024 · 2 comments
Labels

Comments

@ysj2009
Copy link

ysj2009 commented Nov 20, 2024

Hi, I am trying to convert the pixels of segmentation result (some area of an image) to camera coordinate and then to a 2d grid map, I have been trying to use the function rs2_deproject_pixel_to_point to do this, but it is too slow because there are so many pixels to process.
Later I found out about the opencv_pointcloud_viewer.py

        points = pc.calculate(depth_frame)
        pc.map_to(mapped_frame)

        # Pointcloud data to arrays
        v, t = points.get_vertices(), points.get_texture_coordinates()
        verts = np.asanyarray(v).view(np.float32).reshape(-1, 3)  # xyz

which convert the depth_frame to pointcloud data, in it the verts data in it looks like what I needed but I am not sure.
Or is there a better way to do it?
Thanks.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Nov 20, 2024

Hi @ysj2009 They are not the same but have a similar result.

Using pc.map_to and pc.calculate instead of rs2_deproject_pixel_to_point provides more accurate results if depth to color alignment is being used. In practice though, the difference in accuracy between the two methods is small. If pc.calculate works well for you then I would certainly recommend continuing to use it.

The only better method than pc.calculate in terms of performance speed would be rs2_project_color_pixel_to_depth_pixel, which provides a depth value for a single coordinate by converting an RGB color pixel into a depth pixel, so that you do not need to burden the computer with processing by depth-color aligning the entire image.

@MartyG-RealSense
Copy link
Collaborator

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

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