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

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 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?"@http://cs.stackexchange.com/, 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,

( 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).

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

Sort by » oldest newest most voted

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 recall the equations in case the link is no more accessible.

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

Note:

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

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!

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

I had read the course materia](http://www-lar.deis.unibo.it/people/cmelchiorri/Files_Robotica/FIR_03_Rbody.pdf)l 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?

( 2017-03-13 07:50:45 -0500 )edit

Official site

GitHub

Wiki

Documentation