title: OpenCV Decompose Projection Matrix euler angle wrong direction?
body: <p><strong>Situation:</strong> I'm trying to estimate head pose. I have calibrated my camera and got the camera matrix. I have a 3D model that correspond to the image points. I find the pose and get the rotation and translation vectors:</p>
  
  <p><code>_, rvec, tvec = cv2.solvePnP(model_points, image_points, camera_matrix, dist_coeffs, flags=...)</code></p>
  
  <p>I then obtain the rotation matrix from the rotation vector:</p>
  
  <p><code>rotation_matrix, _ = cv2.Rodrigues(rvec)</code></p>
  
  <p>Now, I decided to look at Euler angles. I create projection matrix as follows:</p>
  
  <p><code>projection_matrix = camera_matrix.dot(np.hstack((rotation_matrix, tvec)))</code></p>
  
  <p>So my projection matrix is now 3x4. I then get the Euler angles:</p>
  
  <p><code>angles = cv2.decomposeProjectionMatrix(projection_matrix)[-1]</code></p>
  
  <p><strong>Problem:</strong> I found an alternative way to get the Euler angles in this post (<a href="https://stackoverflow.com/questions/14515200/python-opencv-solvepnp-yields-wrong-translation-vector">Python Opencv SolvePnP yields wrong translation vector</a>), which according to the author should give the same result as my angles (as it did for them):</p>
  
  <pre><code> y_rot = math.asin(rotation_matrix[2][0])
   x_rot = math.acos(rotation_matrix[2][2]/math.cos(y_rot))
   z_rot = math.acos(rotation_matrix[0][0]/math.cos(y_rot))
   y_rot_angle = y_rot *(180/3.1415)
   x_rot_angle = x_rot *(180/3.1415)
   z_rot_angle = z_rot *(180/3.1415)
  </code></pre>
  
  <p>What my angles from decompose projection matrix gives:</p>
  
  <p><code>[164.17979619  19.45087415   1.95279565]</code></p>
  
  <p>What this other solution gives:</p>
  
  <p><code>[164.18463841290048, -19.451447820154847, 1.9528532437807946]</code></p>
  
  <p>The scalar values are the same, but the y angle rotation has a different direction. I was wondering - maybe I have misunderstood something?</p>