Search⌘ K
AI Features

Draw Eyeliner on the Eyes

Explore how to create a Python utility that applies virtual eyeliner to eyes in facial images. Learn to gather eye landmark points, interpolate smooth curves, and draw eyeliner digitally with MediaPipe and OpenCV. Gain hands-on experience in virtual makeup application for enhanced facial appearance.

Introduction

Eyeliner is a makeup product designed to apply color to the area around the eyes in order to accentuate and highlight their appearance. Precision and some technique is needed to apply eyeliner. Uneven eyeliner can potentially make the eye feel unbalanced and bottom heavy.

Objective

This lesson will builds a virtual utility that allows us to experiment with a new look and find the eyeliner that suits us best.

Dependencies

We’ll use the following external Python libraries:

Library

Version

mediapipe

0.8.9

opencv-python

4.4.0.46

numpy

1.19.4

scipy

1.5.4

filetype

1.0.7

Let’s code the utility!

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

The getLeftEyeLandmarkPts function

This function gathers the coordinates of the left eye’s landmark points. The output of this function is an array of two elements that represent the coordinates of the upper and lower eyelids. Let’s define this function.

  • Lines 5–6 shift the extreme points of the eye by a preset value LINER_EXTENSION_POINTS to make the eyeliner thicker.

  • Line 9 ...