Ask Your Question

How to derive camera position from solvePnP? Not a repeated question.

asked 2017-03-13 04:40:19 -0500

yorkhuang gravatar image

updated 2017-03-13 04:40:52 -0500

Hi, can someone help me? From the post, "camera-position-in-world-coordinate-from-cvsolvepnp"@ stackoverflow, it gave the answer of how to derive camera position in world coordinate from cv::solvePnP. However, I still can not get a correct solution from that page. My experiment is facing a wall with a poster and move straight toward the poster step by step. Unfortunately, the trace of the sequence of camera's coordinates are not a straight line. From my understanding, solvePnP() will return the rotation and translation of the object in camera coordinate system. Notice that, they are object's rotation and translation in camera coordinate system. So, the whole question become: Give a poster's rotation and translation in camera coordinate system, how can we derive camera's position in poster's original world space? From my understand go 3D computer graphics, I am skeptical about the solution from above post. Can someone help me to solve the puzzle. Thanks,

edit retag flag offensive close merge delete


After further search the Internet, from the post, "How to find the position of camera given the known world coordinate of objects?"@, it seem that we need to further consider camera's intrinsic parameter when we want to derive camera's world position from the return value of solvePnP. Am I correct? Pleas help. Thank you,

yorkhuang gravatar imageyorkhuang ( 2017-03-13 05:14:41 -0500 )edit

@yorkhuang The link you mention give the exact same answer than me (I didn't bother to consult the link).

Eduardo gravatar imageEduardo ( 2017-03-13 08:37:05 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2017-03-13 05:13:43 -0500

Eduardo gravatar image

updated 2017-03-13 05:44:42 -0500

What you are looking for is called Homogeneous transformation matrix.

To get the 3D coordinate of the camera in the poster frame, assuming a known camera pose, you just have to compute what is called the inverse of the homogenous matrix (see this course, page 72, Ridig Body Motion – Homogeneous Transformations by Claudio Melchiorri).

I strongly recommend to read a course about homogeneous transformation (the one linked should be good).

I recall the equations in case the link is no more accessible.



The superscript t in cRp^t simply means the transpose of matrix.


solvePnP() returning a rotation vector and a translation vector, you will have to use Rodrigues() to compute the rotation matrix from the rotation vector.

edit flag offensive delete link more


Thank you for Eduardo's answer. However, according to your equation, it is exactly the same as the post, "camera-position-in-world-coordinate-from-cvsolvepnp"@ stackoverflow. I tried that already and had no luck at all. Am I misunderstand your answer? Thanks again for your kindness help!

yorkhuang gravatar imageyorkhuang ( 2017-03-13 05:40:16 -0500 )edit

I had read the course materia]( provided by Eduardo and still not solve my doubt about how to derive the camera position from solvePnP(). My main peradventure is the rotation vector and a translation vector from solvePnP() is the object in the camera coordinate system. Are we really can use these two vectors to compute the camera pose from equations above?

yorkhuang gravatar imageyorkhuang ( 2017-03-13 07:50:45 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-03-13 04:40:19 -0500

Seen: 563 times

Last updated: Mar 13 '17