Issue in OpenCV sample tutorial for real time pose estimation

asked 2018-04-15 19:31:39 -0600

malharjajoo gravatar image

updated 2018-04-15 19:40:57 -0600


I was trying out the real time pose estimation tutorial from OpenCV ( this tutorial ), 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 and rot2euler from the C++ source code for the tutorial).

I am aware that there are 6-types of Tait-bryan 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 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


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)]
edit retag flag offensive close merge delete



Answered in the corresponding issue thread.

In short, the references used for euler2rot and rot2euler are these two links:

With the following correspondences:

  • heading is angle for Y1
  • attitude is angle for Z2
  • bank is angle for X3
Eduardo gravatar imageEduardo ( 2018-04-16 10:10:13 -0600 )edit


Thanks for pointing out the source but I still have a query -

  • The sample tutorial code uses the convention (as seen above) for obtaining the Euler angles from the output of the Rodrigues function.

How can it assume that Rodrigues provides the 3x3 rotation matrix in Y-Z-X convention ?

malharjajoo gravatar imagemalharjajoo ( 2018-04-16 11:25:20 -0600 )edit