Ask Your Question

What represents the output of SolvePnP?

asked 2015-07-18 20:37:04 -0500

Banquin gravatar image

Hi there, Im working on object tracking, for this i used SURF for keypoints detection and matching, findHomography(), which gave me the corners of the object im tracking in the video frame, and finally, i am using solvePnP to get the 3d position of the object from the camera. The code i've got is working perfectly, but I dont understand the results.

I mean, the tvector from solvePnp() got the x,y,z coordinates of the object in which frame, to what origin? I dont know, but when im facing the object directly, two of the three coordinates of the tvector show me negative values. I cant understand why.

Maybe someone can help me, or give me a link where this is explained


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-07-19 17:22:31 -0500

Eduardo gravatar image

updated 2015-07-19 17:35:07 -0500

The function solvePnP will return the rotation and translation vectors such as we have:

image description

[X Y Z] are the 3D coordinates in the object frame and [u v] the 2D coordinates in the image frame.

So rvec (see Rodrigues to transform a rotation vector to a rotation matrix and vice versa) and tvec are the rotation and translation vectors that express the camera pose. With these information, you can pass from an object frame coordinate to a camera frame coordinate.

Another thing is that the when we change the coordinate from one frame to another frame, the rotation operation operates first. That means the translation vector operates in the camera frame in our case.

You should draw the different frames to get a better view of the problem.

More information on transformation matrices here (in 2D, in 3D).

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-07-18 20:37:04 -0500

Seen: 4,190 times

Last updated: Jul 19 '15