Member-only story
OpenCV Series — 9— Virtual Makeup — Hats on Head
In this post, we are going to see how we can use Dlib’s face detection landmarks to augment a hat or cap 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 augmented hat.
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 rounded to 300)
dist =…