OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sun, 15 Apr 2018 19:31:39 -0500Issue in OpenCV sample tutorial for real time pose estimationhttp://answers.opencv.org/question/189414/issue-in-opencv-sample-tutorial-for-real-time-pose-estimation/Hi,
I was trying out the real time pose estimation tutorial from OpenCV ( [this tutorial](https://docs.opencv.org/3.3.0/dc/d2c/tutorial_real_time_pose.html) ), and while looking into the source code, I may have found a (possible) inconsistency -
The functions for converting between Rotation Matrix and Euler Angles ( please see [euler2rot](https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp#L229) and [rot2euler](https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp#L189) from the C++ source code for the tutorial).
I am aware that there are **6-types** of [Tait-bryan](https://en.wikipedia.org/wiki/Euler_angles) angles (they are colloquially referred to as **Euler Angles** ).
**My issue:**
- The above source code functions **do not** adhere to any of the 6 types. I checked a few sources to verify this -
From the [section on wikipedia page](https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix) and even wrote a simple Matlab script using symbolic variables ( please see below, at the end of the question ).
- **The source code in the functions seems to correspond to the Y-Z-X Tait bryan angles, but with the pitch and yaw interchanged.** Why is this the case ? (Does this have something to do with the fact that the camera's coordinate axes has z-facing forward, y-facing downward and x-facing right ? )
- And finally, I think, Z-Y-X Tait Bryan angles are the industry standard for robotics , hence is there any particular reason for using Y-Z-X (with the pitch and yaw interchanged, as noticed above) ?
**================= Matlab script below for reference ============**
syms roll
syms pitch
syms yaw
Rx = [1 0 0; 0 cos(roll) -sin(roll); 0 sin(roll) cos(roll)];
Ry = [cos(pitch) 0 sin(pitch); 0 1 0; -sin(pitch) 0 cos(pitch)];
Rz = [cos(yaw) -sin(yaw) 0; sin(yaw) cos(yaw) 0; 0 0 1];
R_Y_Z_X = Ry * Rz * Rx
**Output**:
R_Y_Z_X =
[ cos(pitch)*cos(yaw), sin(pitch)*sin(roll) - cos(pitch)*cos(roll)*sin(yaw), cos(roll)*sin(pitch) + cos(pitch)*sin(roll)*sin(yaw)]
[ sin(yaw), cos(roll)*cos(yaw), -cos(yaw)*sin(roll)]
[ -cos(yaw)*sin(pitch), cos(pitch)*sin(roll) + cos(roll)*sin(pitch)*sin(yaw), cos(pitch)*cos(roll) - sin(pitch)*sin(roll)*sin(yaw)]malharjajooSun, 15 Apr 2018 19:31:39 -0500http://answers.opencv.org/question/189414/