接着系列二,继续开始我们face_recognition项目.
face_recognition项目.为什么能识别人脸,是因为人脸有面部关键点。
案例:提取鞠婧祎面部关键点
在knowe_people文件夹中创建find_facial_features_in_picture.py文件并写入以下代码:
from PIL import Image, ImageDraw
import face_recognition
# Load the jpg file into a numpy array
image = face_recognition.load_image_file("鞠婧祎.jpg")
# Find all facial features in all the faces in the image
face_landmarks_list = face_recognition.face_landmarks(image)
print("I found {} face(s) in this photograph.".format(len(face_landmarks_list)))
# Create a PIL imagedraw object so we can draw on the picture
pil_image = Image.fromarray(image)
d = ImageDraw.Draw(pil_image)
for face_landmarks in face_landmarks_list:
# Print the location of each facial feature in this image
for facial_feature in face_landmark