首页 > 其他 > 详细

face_recognition人脸识别

时间:2019-06-06 11:26:15      阅读:167      评论:0      收藏:0      [点我收藏+]

对亚洲人识别准确度有点差,具体安装:https://www.cnblogs.com/ckAng/p/10981025.html

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import face_recognition

# Load the jpg files into numpy arrays
known1_image = face_recognition.load_image_file("img/test10.jpg")
known2_image= face_recognition.load_image_file("img/test11.jpg")
unknown_image = face_recognition.load_image_file("img/test12.jpg")

# Get the face encodings for each face in each image file
# Since there could be more than one face in each image, it returns a list of encodings.
# But since I know each image only has one face, I only care about the first encoding in each image, so I grab index 0.
try:
    known1_face_encoding = face_recognition.face_encodings(known1_image)[0]
    known2_face_encoding = face_recognition.face_encodings(known2_image)[0]
    unknown_face_encoding = face_recognition.face_encodings(unknown_image)[0]
except IndexError:
    print(
        "I wasn‘t able to locate any faces in at least one of the images. Check the image files. Aborting..."
    )
    quit()

known_faces = [known1_face_encoding, known2_face_encoding]

# results is an array of True/False telling if the unknown face matched anyone in the known_faces array
results = face_recognition.compare_faces(known_faces, unknown_face_encoding)

print("Is the unknown face a picture of known1_image? {}".format(results[0]))
print("Is the unknown face a picture of known2_image? {}".format(results[1]))
print(
    "Is the unknown face a new person that we‘ve never seen before? {}".format(
        not True in results
    )
)

  

face_recognition人脸识别

原文:https://www.cnblogs.com/ckAng/p/10983901.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!