Detect Face Shape

Let’s learn how to identify your face shape.

Introduction

Identifying our correct face shape opens the door for us to craft the perfect look. Discovering our face shape can help with the following:

  • Choosing a suitable hairstyle that complements face shape.
  • Finding the perfect pair of glasses.
  • Applying makeup.
  • Picking a flattering facial hair pattern, like a beard, goatee, or moustache.

Understanding our face shape helps simplify our shopping experience and ensures that we find the perfect style.

Objective

This lesson will help us break down the face shape identification process into smaller steps, which will be illustrated through the functions of a lightweight detector that has been developed using Python.

Dependencies

We’ll be using the following external Python libraries:

Library

Version

mediapipe

0.8.9

opencv-python

4.4.0.46

numpy

1.19.4

Pillow

8.0.1

filetype

1.0.7

Let’s code the utility!

Let’s take a look at the key functions of this utility.

The calculate_Euclidean_Distance function#

This function calculates the Euclidean distance between two landmark points specified as parameters. Let’s take a look at this function.

  • Lines 4–7 get the x and y coordinates of the specified landmark points. (x1, y1) are the coordinates of one point. (x2, y2) are the coordinates of the other point.
  • Lines 9–14 calculate the distance based on the following calculation formula:

d=(x2x1)2+(y2y1)2d = \sqrt{ (x2 - x1)^2 + (y2 - y1)^2 } ...