OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 16 Apr 2018 10:54:16 -0500Obtaining Euler angles from Rodrigues Rotation Matrixhttp://answers.opencv.org/question/189455/obtaining-euler-angles-from-rodrigues-rotation-matrix/ Hi,
I wish to extract Euler angles from the **rvec** output parameter of [cv::solvePnp](https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#bool%20solvePnP(InputArray%20objectPoints,%20InputArray%20imagePoints,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20OutputArray%20rvec,%20OutputArray%20tvec,%20bool%20useExtrinsicGuess,%20int%20flags)).
I understand that 3x1 rvec needs to be passed on to the [Rodrigues](https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20Rodrigues(InputArray%20src,%20OutputArray%20dst,%20OutputArray%20jacobian)) function to obtain the 3x3 rotation matrix.
But to obtain Euler Angles, I need to use a fixed convention ( see [this](https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix) , for example Z-Y-X,etc ) which requires the rotation matrix to be obtained from a **permutation (fixed order) of multiplication of Matrices** ,
**eg: for Z-Y-X convention,
R_resultant = Rz * Ry * Rx**.
I have looked into the source code [here](https://github.com/opencv/opencv/blob/master/modules/calib3d/src/calibration.cpp#L251) for Rodrigues function but don't quite understand how the matrix is formed Hence -
**My Question**: What is the **convention** (Z-Y-X, X-Y-Z, etc) of the formation of the 3x3 Rotation matrix obtained from Rodrigues ? Without this information I cannot obtain Euler angles. I have seen [this tutorial](https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp#L189) for real time pose estimation, but unfortunately I don't understand the assumption for the convention (and hence I had made another question for that - [here](http://answers.opencv.org/question/189414/issue-in-opencv-sample-tutorial-for-real-time-pose-estimation/?comment=189453#post-id-189453)).malharjajooMon, 16 Apr 2018 10:54:16 -0500http://answers.opencv.org/question/189455/OpenCV SolvePnP strange valueshttp://answers.opencv.org/question/176922/opencv-solvepnp-strange-values/Hello,
I experiment on a project.
I use **SolvePnP** to find rotation vector on an object.
Since the values are hard to understand, I used 3D software to define specific values that I am trying to find with OpenCV.
I've got a plane in the center on my scene. I apply rotations on X, Y or Z.
In example bellow, rotations are defined on :
**x=30°
y=0°
z=30°**
I've got good values for focalLength, fov, etc.
![image description](/upfiles/1508940197829013.jpg)
As you can see, the **cv2.projectPoints** works perfectly on my image.
When I call **SolvePnP**, the **rvecs returns strange values**.
For rotation X, I've got 28.939°
For rotation X, I've got 7.916°
For rotation Z, I've got 29.02031°
So when I try to map a plane with WebGL, I've got the result on image bellow (red plane)
![image description](/upfiles/15089407414127149.jpg)
**So here is my question.
Why SolvePnP doesn't return x:30°, y:0° and z:30° !
It's very strange no ???**
Do I have to use **Rodrigues** somewhere? If yes, how ?
Is there a lack of precision somewhere?
Thanks
Loïc
kopacabana73Wed, 25 Oct 2017 09:18:24 -0500http://answers.opencv.org/question/176922/Rotation 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.sourmanbTue, 07 Jun 2016 01:19:52 -0500http://answers.opencv.org/question/95782/