Face Alignment
Let’s learn to align the faces detected in a digital image.
Introduction
Face alignment revolves around spotting the geometric structure of a face shown in a digital image and trying to achieve a canonical alignment of the detected face based on translation, scale, and rotation. Face alignment plays a key role in most face analysis functions and is frequently used as a preprocessing phase in many face recognition and 3D face reconstruction applications.
Objective
This lesson will demonstrate the face alignment process as a data normalization process while relying on the facial landmarks that are extracted using the MediaPipe library. As a result, the rotated face image will have the eyes lying on a horizontal line.
The face alignment process consists of the following steps:
- Detect the faces within a digital image.
- Localize the eyes of each face detected.
- Grabb the center points for each eye detected.
- For each face, draw a line between the center points of its underlying eyes. This line will be diagonal if the face in question is inclined.
- Draw a horizontal line between the eyes on each face.
- Calculate the rotation angle.
- Rotate the face image based on the calculated rotation angle.
Dependencies
The following Python external ...