IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.63k stars 4.83k forks source link

Excuse me, is there an interface for converting world coordinate system to pixel coordinate system #13490

Closed linxizi closed 2 days ago

linxizi commented 3 weeks ago

During the project process, we want to convert the world coordinate system of known points into a pixel coordinate system through an interface, But I can't find any interface in the python language

MartyG-RealSense commented 3 weeks ago

Hi @linxizi If you have converted 2D pixel coordinates into 3D world coordinates with the instruction rs2_deproject_pixel_to_point then you can convert the 3D points back to 2D pixel coordinates with the instruction rs2_project_point_to_pixel

The link below has an example of a RealSense Python script for deprojecting 2D to 3D, and then projecting 3D back to 2D.

https://stackoverflow.com/questions/50716249/mapping-depth-pixels-to-colour-pixels-using-pyrealsense2

depth_point = rs.rs2_deproject_pixel_to_point(depth_intrin, depth_pixel, depth_scale)
color_point = rs.rs2_transform_point_to_point(depth_to_color_extrin, depth_point)
color_pixel = rs.rs2_project_point_to_pixel(color_intrin, color_point)

In regard to an interface, do you mean that you would like to perform the 3D to 2D conversion through a graphical user interface (GUI) please? If so then there are only a limited number of available ways to do so.

One way would be to use pyglet, as demonstrated by the RealSense SDK's 'pyglet_pointcloud_viewer.py' example program:

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/pyglet_pointcloud_viewer.py

The other way would be to use Tkinter.

https://support.intelrealsense.com/hc/en-us/community/posts/4406041385875-TKinter-python-with-librealsense2

MartyG-RealSense commented 1 week ago

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

MartyG-RealSense commented 2 days ago

Case closed due to no further comments received.