Code example demonstrating how to detect eyes, nose, lips, and jaw with dlib, OpenCV, and Python
This tutorial will help you to extract the cordinates for facial features like eyes, nose, mouth and jaw using 68 facial landmark indexes.
The facial landmark detector implemented inside dlib produces 68 (x, y)-coordinates that map to specific facial structures. These 68 point mappings were obtained by training a shape predictor on the labeled iBUG 300-W dataset.
Below we can visualize what each of these 68 coordinates map to:
Examining the image, we can see that facial regions can be accessed via simple Python indexing (assuming zero-indexing with Python since the image above is one-indexed):
These mappings are encoded inside the FACIAL_LANDMARKS_IDXS dictionary inside face_utils of the imutils library.
Project uses below python packages:
pip install requirements.txt
python detect_face_features.py --shape-predictor shape_predictor_68_face_landmarks.dat --image images/image_1.jpg