OpenCV Series — 8 — Virtual Makeup — Augment Sunglasses on eyes

Rajathithan Rajasekar
4 min readOct 11, 2020

In this post, we are going to see how we can use Dlib’s face detection landmarks to augment the sunglasses to a person’s image. In my previous Dlib posts i had explained where to download the Dlib pre-trained 68 point face prediction model and the code to detect the landmark points on a facial image.

Now, we will go through the steps involved in identifying the right points in a face image to place the sunglasses on the eyes.

Step: 1:

Detect the landmark points in an image

Step: 2:

Detect the distance between points.

Identify the distance between Points[0] and Points[16] to get the length of the face and round it to the nearest hundred value.

import math
dist = points[16][0] - points[0][0]
# Round the distance between Point[0] and Point[16] landmark
# on the x-axis to the nearest 100 values
# (i.e a distance 278 will be…

--

--

Rajathithan Rajasekar
Rajathithan Rajasekar

Written by Rajathithan Rajasekar

I like to write code in Python . Interested in cloud , dataAnalysis, computerVision, ML and deepLearning. https://rajathithanrajasekar.medium.com/membership