我遇到了MTCNN网络的实现,它能够检测我们在三个轴上的头部运动,分别是偏航、翻滚和俯仰。
以下是关键要素:
以下是关键要素:
bbox, points = detector.detect_faces(frame)
points
给出了从网络预测中得到的关键点列表,如下图所示:
绘图函数:
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)
现在为了检测不同轴上的一些头部运动,定义了航向和横摇函数。
def Roll(points):
return points[6] - points[5]
def Yaw(points):
le2n = points[2] - points[0]
re2n = points[1] - points[2]
return le2n - re2n
现在说到:
"Roll 是绕 x 轴旋转(在 -180 到 180 度之间)
Yaw 是绕 z 轴旋转(在 -180 到 180 度之间)."
那么 Yaw 的功能是如何实现的?
Github:
https://github.com/fisakhan/Face_Pose/blob/master/pose_detection_mtcnn.py