OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 08 Jun 2016 05:28:48 -0500Rotation and Translation questionhttp://answers.opencv.org/question/95782/rotation-and-translation-question/ I've used OpenCV's calibrateCamera function to give me the rvecs and tvecs to try to get the transformation from that of my camera with world coordinates (0,0,0) to that of a chessboard. I'm using it to find the corners of the chessboard with respect to the camera.
I'm confused as to how to apply the rvec and tvec to get the transformation. Do I just do (0,0,0)*rvec + tvec. If this is the case, how do I invert the transformation, as I'll need this for something else as well?
After doing research online I realized I may have to use the Rodrigues() function to get the rotation matrix from rvec, augment that with the tvec, and then add a row of (0,0,0,1) to get a 4x4 transformation matrix. This way, I would be able to get the inverse. However, If that is the case, how do I multiply that by (0,0,0)? Am I just supposed to do (0,0,0,1)*(rotm|tvec, 0,0,0,1)?
I'm not sure which of the two methods to use, I'm doubtful about how to proceed with either of them.Tue, 07 Jun 2016 01:19:52 -0500http://answers.opencv.org/question/95782/rotation-and-translation-question/Answer by AJW for <p>I've used OpenCV's calibrateCamera function to give me the rvecs and tvecs to try to get the transformation from that of my camera with world coordinates (0,0,0) to that of a chessboard. I'm using it to find the corners of the chessboard with respect to the camera.</p>
<p>I'm confused as to how to apply the rvec and tvec to get the transformation. Do I just do (0,0,0)*rvec + tvec. If this is the case, how do I invert the transformation, as I'll need this for something else as well?</p>
<p>After doing research online I realized I may have to use the Rodrigues() function to get the rotation matrix from rvec, augment that with the tvec, and then add a row of (0,0,0,1) to get a 4x4 transformation matrix. This way, I would be able to get the inverse. However, If that is the case, how do I multiply that by (0,0,0)? Am I just supposed to do (0,0,0,1)*(rotm|tvec, 0,0,0,1)?</p>
<p>I'm not sure which of the two methods to use, I'm doubtful about how to proceed with either of them.</p>
http://answers.opencv.org/question/95782/rotation-and-translation-question/?answer=95913#post-id-95913I'm not sure that I understand 100% what you're trying to do, but here goes.
(r,t) in this case represent a rigid transform that convert points from the chessboard coordinate system to the camera coordinate system (I don't know the convention for which one is the *world* coordinate system). You're right about needing the Rodrigues transform, but you have the multiplication order wrong. Say you use Rodrigues to get a rotation matrix R, and you have a point X=[x y z]^T in the chessboard coordinate system (X must be a column-vector). Then to express the point in the world coordinate system, you want R*X + t.
The approach of making the 4x4 matrix should also work. This is based on the concept of **homogeneous coordinates** (might help with Googling). You should be able to just invert that to get the inverse transformation. Again, the order matters. If P is the 4x4 matrix, it should be P*[0 0 0 1]^T(or whatever the vector is, and again, it must be a column vector).
You should also be able to obtain the inverse without homogeneous coordinates. Let's denote it (R',t'). I'm pretty sure R' = R^T (a rotation matrix is orthonormal, so its inverse is just the transpose). And t' = -R^T * t. You could even take both approaches and check that they give basically the same inverse.
Wed, 08 Jun 2016 05:28:48 -0500http://answers.opencv.org/question/95782/rotation-and-translation-question/?answer=95913#post-id-95913