I have encountered implementation of MTCNN network which is able to detect our head movement in 3 axis called Yaw,Roll and Pitch.
Here are crucial elements:
bbox, points = detector.detect_faces(frame)
points
gives me keypoints list from network preduction such as:
Drawing function:
def draw_landmarks(frame, bb, points):
# draw rectangle and landmarks on face
cv2.rectangle(frame,(int(bb[0]),int(bb[1])),(int(bb[2]),int(bb[3])),green,2)
cv2.circle(frame, (points[0], points[5]), 2, (255,0,0), 2)# eye
cv2.circle(frame, (points[1], points[6]), 2, (255,0,0), 2)
cv2.circle(frame, (points[2], points[7]), 2, (255,0,0), 2)# nose
cv2.circle(frame, (points[3], points[8]), 2, (255,0,0), 2)# mouth
cv2.circle(frame, (points[4], points[9]), 2, (255,0,0), 2)
Now to detect some head movement in different axis there was defined Yaw and Roll functions.
def Roll(points):
return points[6] - points[5]
def Yaw(points):
le2n = points[2] - points[0]
re2n = points[1] - points[2]
return le2n - re2n
Now having said that:
"Roll is the rotation about the x axis (between -180 and 180 deg)
Yaw is the rotation about the z axis (between -180 and 180)."
How does exactly Yaw function work here?
Github:
https://github.com/fisakhan/Face_Pose/blob/master/pose_detection_mtcnn.py

