From 3D point to 2D pixel


My task is to draw a line on an opencv window, but I only have the 3D coordinates of the cloud points relative to the camera. So my question is: how can I extract the 2D position of a pixel, given the corresponding 3D location of the cloud point?

Thanks in advance!

Yes, the formulas are simple:

u_screen = (X_world/Z_world)*f_x + c_x
v_screen = (Y_world/Z_world)*f_y + c_y

using the 3D coordinates in the camera frame (COORDINATE_SYSTEM::IMAGE):

You can get f_x, c_x, f_y, and c_y from the camera parameters:

1 Like

Works like a charm! Thank you!

1 Like