[Discourse.ros.org] [Computer Vision / Perception] How to project 3D data into pixel coordinate?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Computer Vision / Perception] How to project 3D data into pixel coordinate?

Joshua Whitley via ros-users


Hello,

 The scenario is I have a RGB-D camera in robot, and by subscribing camera/depth_registered/points (sensor_msgs/PointCloud2) get the point cloud data. What I want is to project the PointCloud2 data into pixel coordinate. My question is that is there any module / library which is hardware independent (the camera could either be Kinect or RealSense or what ever RGB-D camera) could help to do this?

Thanks





---
[Visit Topic](https://discourse.ros.org/t/how-to-project-3d-data-into-pixel-coordinate/2616/1) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Computer Vision / Perception] How to project 3D data into pixel coordinate?

Joshua Whitley via ros-users


You don't need a library for that, just use the [pinhole camera model](https://en.wikipedia.org/wiki/Pinhole_camera_model)
here is a small python function:
def world_to_pixel(self, point):
    x = point[0]
    y = point[1]
    z = point[2]
    px = x*self.K[0][0]/z + self.K[0][2]
    py = y*self.K[1][1]/z + self.K[1][2]
    return np.asarray([px, py])

K is the 3x3 camera matrix you get from camera_info
    self.K[0][0] = cam_info.K[0]
    self.K[0][2] = cam_info.K[2]
    self.K[1][1] = cam_info.K[4]
    self.K[1][2] = cam_info.K[5]
    self.K[2][2] = 1





---
[Visit Topic](https://discourse.ros.org/t/how-to-project-3d-data-into-pixel-coordinate/2616/2) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Computer Vision / Perception] How to project 3D data into pixel coordinate?

Joshua Whitley via ros-users
In reply to this post by Joshua Whitley via ros-users


Even simpler: all the examples you gave of "depth_registered" point clouds
are *organized*: point (u, v) corresponds to pixel (u, v) in the image.

If you want the points in a different RGB frame and you have the depth
image, it's best to register the depth image into that RGB frame and then
calculate the point cloud (which will also be organized). Both can be done
using depth_image_proc.

If you have an arbitrary point cloud, you'll have to use the pinhole camera
model as suggested above.

P.S.: The proper place to ask this kind of question is ROS answers.





---
[Visit Topic](https://discourse.ros.org/t/how-to-project-3d-data-into-pixel-coordinate/2616/3) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Computer Vision / Perception] How to project 3D data into pixel coordinate?

Joshua Whitley via ros-users
In reply to this post by Joshua Whitley via ros-users


Also note that when using the pinhole camera model, multiple points can
correspond to the same pixel, so you might have to do a z buffer check
(only keep the closest pixel).





---
[Visit Topic](https://discourse.ros.org/t/how-to-project-3d-data-into-pixel-coordinate/2616/4) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Computer Vision / Perception] How to project 3D data into pixel coordinate?

Joshua Whitley via ros-users
In reply to this post by Joshua Whitley via ros-users


@mehditlili @Martin_Guenther really appreciate your helps. thank you very much.





---
[Visit Topic](https://discourse.ros.org/t/how-to-project-3d-data-into-pixel-coordinate/2616/5) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>