Hi!
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): https://www.stereolabs.com/docs/api/group__Core__group.html#ga1114207cbac18c1c0e4f77a6b36a8cb2
COORDINATE_SYSTEM::IMAGE
You can get f_x, c_x, f_y, and c_y from the camera parameters: https://www.stereolabs.com/docs/api/structsl_1_1CameraParameters.html
Works like a charm! Thank you!