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:

  1. Detect the faces within a digital image.
  2. Localize the eyes of each face detected.
  3. Grabb the center points for each eye detected.
  4. 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.
  5. Draw a horizontal line between the eyes on each face.
  6. Calculate the rotation angle.
  7. Rotate the face image based on the calculated rotation angle.

Dependencies

The following Python external ...