Situation: 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:
_, rvec, tvec = cv2.solvePnP(model_points, image_points, camera_matrix, dist_coeffs, flags=...)
I then obtain the rotation matrix from the rotation vector:
rotation_matrix, _ = cv2.Rodrigues(rvec)
Now, I decided to look at Euler angles. I create projection matrix as follows:
projection_matrix = camera_matrix.dot(np.hstack((rotation_matrix, tvec)))
So my projection matrix is now 3x4. I then get the Euler angles:
angles = cv2.decomposeProjectionMatrix(projection_matrix)[-1]
Problem: I found an alternative way to get the Euler angles in this post (Python Opencv SolvePnP yields wrong translation vector), which according to the author should give the same result as my angles (as it did for them):
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)
What my angles from decompose projection matrix gives:
[164.17979619 19.45087415 1.95279565]
What this other solution gives:
[164.18463841290048, -19.451447820154847, 1.9528532437807946]
The scalar values are the same, but the y angle rotation has a different direction. I was wondering - maybe I have misunderstood something?