Ask Your Question
0

Transform world coordinate to Camera Coordinate using SolvePNP?

asked 2017-09-05 03:48:32 -0600

ibrahim_5403 gravatar image

I estimate rvec and tvec using solvePNP . How can I convert the (0,0,0) point from world coordinate to the camera coordinate using rvec and tvec? Our model points is shown below: image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-09-05 20:58:01 -0600

Tetragramm gravatar image

To invert both rvec and tvec, use the following.

Mat R;
Rodrigues(rvec, R);
R = R.t();
tvec = -R*tvec;
Rodrigues(R, rvec);
edit flag offensive delete link more

Comments

Thank you very much for your answer. Would you clear me, please? After inverting we have to create transformation matrix and multiply it by the homogeneous coordinate of (0,0,0). Is that OK?

ibrahim_5403 gravatar imageibrahim_5403 ( 2017-09-05 21:45:13 -0600 )edit

Clear you?

What you start with is the location of the (0,0,0) point relative to the camera. After you invert rvec and tvec you have the location of the camera relative to the (0,0,0) point and the axes attached to it. What information exactly are you trying to get?

Tetragramm gravatar imageTetragramm ( 2017-09-05 22:14:00 -0600 )edit

Thanks. In the above figure, I have shown an image. the image contains a rectangular object. The model points are also shown in the figure. Now I have estimated the rvec and tvec using SolvePNP. In my experiment, I will move the image to the horizontal axis. After that I want to transform the center point of the rectangle, that means (0,0,0), 3D point, into a 3D points in the camera coordinate system. I want to see the Z value of the transform point, that means the distance between camera and rectagular object.

ibrahim_5403 gravatar imageibrahim_5403 ( 2017-09-06 19:24:27 -0600 )edit

I think you can just use projectPoints() with an identity camera matrix and zero distortion coefficients to transform points in object frame to camera frame.

Eduardo gravatar imageEduardo ( 2017-09-07 03:32:47 -0600 )edit

The distance between the camera and the (0,0,0) point is just the norm of the tvec that comes from solvePnP. So sqrt(x^2+y^2+z^2). That is the straight line distance. The distance from the camera focal plane to the point is the z value of the tvec that comes from solvePnP. At least, i think the second one. I'd need to test that.

Tetragramm gravatar imageTetragramm ( 2017-09-07 23:09:01 -0600 )edit

Thanks to all. @ Tetragramm you are right. It is OK now.

ibrahim_5403 gravatar imageibrahim_5403 ( 2017-09-10 05:20:26 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-09-05 03:48:32 -0600

Seen: 4,305 times

Last updated: Sep 05 '17