def test_landmarks(self): image = io.load_image("faces/albert-einstein.jpg") faces = detect_faces(image) self.assertTrue(len(faces) == 1) face = faces[0] landmarks = face_landmarks(image, face) self.assertTrue(len(landmarks) == 68)
def test_features(self): image = io.load_image("faces/albert-einstein.jpg") faces = detect_faces(image) self.assertTrue(len(faces) == 1) face = faces[0] landmarks = face_landmarks(image, face) features = extract_face_features(image, landmarks.shape) self.assertTrue(len(features) == 128)
def test_faces(self): for image_file in glob("faces/*.jpg"): image = io.load_image(image_file) faces = detect_faces(image, min_score=1.0) face = faces[0] landmarks = face_landmarks(image, face) image = visualize( image, face, landmarks=landmarks, thickness=1, color=(0, 0, 255), ) cv2.imshow('image', image) cv2.imwrite('images/' + image_file, image) cv2.waitKey(0)
def get_features(self, image): return extract_face_features( image, face_landmarks(image, detect_faces(image, min_score=1)[0]).shape)
def test_einstein(self): image = io.load_image("faces/albert-einstein.jpg") faces = detect_faces(image) self.assertTrue(len(faces) == 1) self.assertTrue(faces[0].width() == 156)