Drawing a line on the ground

asked 2020-05-05 03:04:02 -0600

Niko1 gravatar image

Hello everybody,

I would like to draw "perspective" line on the ground (z = 0) in the middle of the image starting at bottom and moving to top of image (in u,v coordinates). This line should point into the image. Which should be the z-coordinate of the camera coordinates.

My camera Matrix is calculated by calibrateCamera with a chessboard pattern. The chessboard is positioned on the ground (z = 0).Within this matrix there is cx = 399.5, cy = 299.5 (my Image is 800x600).

I would enter the coordinates of the line in world coordinates. Therefore I would set the world coordinates to the camera coordinates. I have the rvec and tvec between the chessboard and the camera. The coordinates of the chessboard I call "body-coordinates". To be able to use the projectPoints function, I need the calculate my line coordinates from camera to body-coordinates. I do this by X_body = R.inv * X_cam - R.inv * tvec

Now, I can call the function projectPoints. But I want my line to start at the image coordinate (u=400, v=600) can I reset the cx and cy values in the cameraMatrix to cx = 400 and cy = 600, to achieve this?

edit retag flag offensive close merge delete

Comments

If you have like this projectPoints(x, y) or projectPoints(img, x, y): projectPoints(600, 400) or projectPoints(img, x, y)

supra56 gravatar imagesupra56 ( 2020-05-06 03:31:56 -0600 )edit