[ros-users] [Discourse.ros.org] [Computer Vision / Perceptio…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Mehdi Tlili via ros-users
Date:  
To: ros-users
Subject: [ros-users] [Discourse.ros.org] [Computer Vision / Perception] How to project 3D data into pixel coordinate?


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

http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>