FaceAligner: added 'head_mode', can be used with HEAD models.

This commit is contained in:
iperov 2021-08-07 19:16:25 +04:00
commit 72166cc190
11 changed files with 177 additions and 40 deletions

View file

@ -1,7 +1,23 @@
import math
import numpy as np
import numpy.linalg as npla
def rotation_matrix_to_euler(R : np.ndarray) -> np.ndarray:
sy = math.sqrt(R[0,0] * R[0,0] + R[1,0] * R[1,0])
singular = sy < 1e-6
if not singular :
x = math.atan2(R[2,1] , R[2,2])
y = math.atan2(-R[2,0], sy)
z = math.atan2(R[1,0], R[0,0])
else :
x = math.atan2(-R[1,2], R[1,1])
y = math.atan2(-R[2,0], sy)
z = 0
return np.array([x, y, z])
def segment_length(p1 : np.ndarray, p2 : np.ndarray):
"""
p1 (2,)