1996scarlet/Dense-Head-Pose-Estimation

Where can I find the camera matrix params derived from the model for a given frame?

Tetsujinfr opened this issue · 2 comments

thanks

Ok so I guess this is
self._get_camera_matrix = partial(self._interpreter.get_tensor,
output_details[0]["index"])

in BaseTFLiteFaceAlignment ?

Yes, we can get the camera_matrix R directly from the model output.

self._get_camera_matrix = partial(self._interpreter.get_tensor,
output_details[0]["index"])

def _postprocessing(self, M):
iM = cv2.invertAffineTransform(M)
R = self._get_camera_matrix()[0]
landmarks = self._decode_landmarks(iM)
return landmarks, R

Then, we can decompose matrix to ruler angle

def pose(frame, results, color):
landmarks, params = results
# rotate matrix
R = params[:3, :3].copy()
# decompose matrix to ruler angle
euler = rotationMatrixToEulerAngles(R)
print(f"Pitch: {euler[0]}; Yaw: {euler[1]}; Roll: {euler[2]};")
draw_projection(frame, R, landmarks, color)