How to do it...

Follow the steps listed for the face morphing implementation:

  1. First, use the dlib library's face detector and shape predictor (as you did in the Face alignment with dlib recipe) to automatically compute the facial landmarks from the human face by implementing the get_face_landmarks() function. It takes the input image, a Boolean flag indicating whether to add the boundary points or not, and the dlib library's shape_predictor model's path:
def get_face_landmarks(img, add_boundary_points=True, predictor_path = 'images/shape_predictor_68_face_landmarks.dat'): detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor(predictor_path)
  1. Compute 68 facial landmarks (keypoints) using dlib for each face detected ...

Get Python Image Processing Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.