Amazing and easy face landmarks detector with dlib library.
All thanks to Adrian Rosebrock (from pyimagesearch) for making great tutorials. This project is inspired from his blog: Facial landmarks with dlib, OpenCV, and Python. I have included the author's code and the one i wrote my self as well.
- Steps involved:
- Localize the face in the image
- Detect the key facial structures on the face ROI
- Assumptions:
- We already have the trained face detector and face landmark detector.
- Variety of things the face detector detects:
- Nose
- Mouth
- Left eye
- Right eye
- Left eyebrow
- Right eyebrow
- Jaw
- Data required for training of dlib's facial landmark detector:
- Training set of labeled facial landmarks on the image.
- Priors: Probability on distance between pairs of input pixels
- The dlib's face detector is an implementation of One Millisecond Face Alignment with an Ensemble of Regression Trees paper by Kazemi and Sullivan (2014).
- 68 coordinates are detected for the given face by the face detector. The image is shown below.

- dlib's framework can be trained to predict any shape. Hence it can be used for custom shape detections as well.
- Used dlib's pre-trained face detector based on the modification of the standard Histogram of Oriented Gradients + Linear SVM method for object detection.
- The face detector used up-scaling before face detection for better results.
- This method works even for multiple faces in the image.
- python (3.7.3)
- opencv (4.1.0)
- numpy (1.61.4)
- imutils (0.5.2)
- dlib (19.17.0)
python facial_landmarks_mine.py --shape-predictor shape_predictor_68_face_landmarks.dat --image images/example_01.jpg
The results are awesome. We can see pretty accurate face landmark detections.
Input
Output
Input
Output
None



