OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Fri, 19 Jun 2015 05:44:54 -0500solvePnp object - to - camera pose.http://answers.opencv.org/question/64315/solvepnp-object-to-camera-pose/ I have read enough about this to know that it is fairly straightforward, but I can't find an example of how to actually do it.
I use solvePnp, and get rvec and tvec matrices back. The rotation and translation, respectively, as a 3x3 matrix and a 3 x 1.
As I understand it, this is the OBJECT transformation matrix, using the camera sensor as the zero point and giving the coordinates of one of the points.
My question is, how exactly do i get the camera pose from this information? I believe i need to invert the matrix?
Wed, 17 Jun 2015 02:57:53 -0500http://answers.opencv.org/question/64315/solvepnp-object-to-camera-pose/Answer by R.Saracchini for <p>I have read enough about this to know that it is fairly straightforward, but I can't find an example of how to actually do it.</p>
<p>I use solvePnp, and get rvec and tvec matrices back. The rotation and translation, respectively, as a 3x3 matrix and a 3 x 1.</p>
<p>As I understand it, this is the OBJECT transformation matrix, using the camera sensor as the zero point and giving the coordinates of one of the points. </p>
<p>My question is, how exactly do i get the camera pose from this information? I believe i need to invert the matrix?</p>
http://answers.opencv.org/question/64315/solvepnp-object-to-camera-pose/?answer=64320#post-id-64320The function **solvePnp** (or **solvePnPRansac**) consider that the 3D points given are in absolute world coordinates, thus it will return a rotation and translation matrix of the *extrinsic matrix* of the camera. That is, a matrix that will convert 3D world coordinates to 3D coordinates relative to the camera centre. If you compute the inverse of said matrix, you will have the camera transform matrix, which will state the camera rotation and translation in relation to the "world".
Note that the rotation is given in Euler angles, so you will need use **cv::Rodrigues** to convert it to a 3x3 rotation matrix. The extrinsic matrix is then a 4x4 matrix in the form
R00 R01 R02 T0
R10 R11 R12 T1
R20 R21 R22 T2
0 0 0 1
you can just use **cv::Mat::inv()** to compute the inverse.Wed, 17 Jun 2015 03:59:13 -0500http://answers.opencv.org/question/64315/solvepnp-object-to-camera-pose/?answer=64320#post-id-64320Comment by stillNovice for <p>The function <strong>solvePnp</strong> (or <strong>solvePnPRansac</strong>) consider that the 3D points given are in absolute world coordinates, thus it will return a rotation and translation matrix of the <em>extrinsic matrix</em> of the camera. That is, a matrix that will convert 3D world coordinates to 3D coordinates relative to the camera centre. If you compute the inverse of said matrix, you will have the camera transform matrix, which will state the camera rotation and translation in relation to the "world". </p>
<p>Note that the rotation is given in Euler angles, so you will need use <strong>cv::Rodrigues</strong> to convert it to a 3x3 rotation matrix. The extrinsic matrix is then a 4x4 matrix in the form</p>
<pre><code>R00 R01 R02 T0
R10 R11 R12 T1
R20 R21 R22 T2
0 0 0 1
</code></pre>
<p>you can just use <strong>cv::Mat::inv()</strong> to compute the inverse.</p>
http://answers.opencv.org/question/64315/solvepnp-object-to-camera-pose/?comment=64479#post-id-64479Hi again, If you have time could you cast your eye over my new question please? Still fighting with solvePnp!
http://answers.opencv.org/question/64410/solvepnp-camera-coordinates/Fri, 19 Jun 2015 05:44:54 -0500http://answers.opencv.org/question/64315/solvepnp-object-to-camera-pose/?comment=64479#post-id-64479Comment by stillNovice for <p>The function <strong>solvePnp</strong> (or <strong>solvePnPRansac</strong>) consider that the 3D points given are in absolute world coordinates, thus it will return a rotation and translation matrix of the <em>extrinsic matrix</em> of the camera. That is, a matrix that will convert 3D world coordinates to 3D coordinates relative to the camera centre. If you compute the inverse of said matrix, you will have the camera transform matrix, which will state the camera rotation and translation in relation to the "world". </p>
<p>Note that the rotation is given in Euler angles, so you will need use <strong>cv::Rodrigues</strong> to convert it to a 3x3 rotation matrix. The extrinsic matrix is then a 4x4 matrix in the form</p>
<pre><code>R00 R01 R02 T0
R10 R11 R12 T1
R20 R21 R22 T2
0 0 0 1
</code></pre>
<p>you can just use <strong>cv::Mat::inv()</strong> to compute the inverse.</p>
http://answers.opencv.org/question/64315/solvepnp-object-to-camera-pose/?comment=64323#post-id-64323Perfect. thank you for the detailed explanation.Wed, 17 Jun 2015 04:16:20 -0500http://answers.opencv.org/question/64315/solvepnp-object-to-camera-pose/?comment=64323#post-id-64323