Complete the code to load an image using OpenCV.
import cv2 image = cv2.[1]('face.jpg')
The function cv2.imread loads an image from a file into memory.
Complete the code to convert the image to grayscale for face landmark detection.
gray = cv2.[1](image, cv2.COLOR_BGR2GRAY)cv2.cvtColor converts images between color spaces, here from BGR to grayscale.
Fix the error in loading the pre-trained face landmark model.
import dlib predictor = dlib.shape_predictor('[1]')
The correct filename for the dlib 68-point face landmark predictor is shape_predictor_68_face_landmarks.dat.
Fill both blanks to detect faces and predict landmarks on the grayscale image.
detector = dlib.get_frontal_face_detector() faces = detector([1]) for face in faces: landmarks = predictor([2], face)
Face detection runs on the grayscale image. The predictor needs the grayscale image and a face rectangle with a second argument 0.
Fill all three blanks to extract landmark points and store them in a list.
landmark_points = [] for n in range(0, [1]): x = landmarks.part(n).[2] y = landmarks.part(n).[3] landmark_points.append((x, y))
The dlib 68-point model has 68 landmarks indexed 0 to 67. Each point has x and y coordinates accessed by .x and .y.