Face detection. A face detector is adopted to provide a face box
containing a human face. Then the face box is expanded and transformed
to a square to suit the needs of later steps.
Facial landmark detection. A custom trained facial landmark detector
based on TensorFlow is responsible for output 68 facial landmarks.
Pose estimation. Once we got the 68 facial landmarks, a mutual PnP algorithms is adopted to calculate the pose.
The marks is detected frame by frame, which result in small variance
between adjacent frames. This makes the pose unstable. A Kalman filter
is used to solve this problem, you can draw the original pose to observe
the difference.
The pre-trained TensorFlow model file is trained with various public
data sets which have their own licenses. Please refer to them before
using this code.