python 人脸识别

╰半橙微兮° 2022-05-16 07:57 344阅读 0赞

python版本 3.7.0
这里写图片描述

1、 安装 cmake

pip install cmake
这里写图片描述

2、安装 boost

pip install boost
这里写图片描述

3、安装 dlib

pip install dlib
这里写图片描述

4、安装 face_recognition

pip install face_recognition
这里写图片描述

5、验证

face_recognition 本地模型路径 要识别图片路径
输出:文件名 识别的人名
这里写图片描述

注意:文件名以人名命名
这里写图片描述

6、寻找人脸位置

face_detection “路径”
输出:人脸像素坐标
这里写图片描述

7、调整灵敏度

face_recognition –tolerance 灵敏度 本地模型路径 要识别图片路径
注:默认0.6,识别度越低识别难度越高
这里写图片描述

8、计算每次面部距离

face_recognition –show-distance true 本地模型路径 要识别图片路径
这里写图片描述

9、只是想知道每张照片中人物的姓名,却不关心文件名,可以这样做:

face_recognition 本地模型路径 要识别图片路径 | cut -d ‘,’ -f2

这里写图片描述

10、加速识别

face_recognition –cpus 使用内核数 本地模型路径 要识别图片路径
使用四核识别:
face_recognition –cpus 4 本地模型路径 要识别图片路径
这里写图片描述
使用全部内核识别:
face_recognition –cpus -1 本地模型路径 要识别图片路径这里写图片描述

11、自动查找图像中的所有面孔

import face_recognition

image = face_recognition.load_image_file(“吴京.jpg”)
face_locations = face_recognition.face_locations(image)

12、识别图像中的面孔并识别他们是谁

  1. import face_recognition
  2. picture_of_me = face_recognition.load_image_file("me.jpg")
  3. my_face_encoding = face_recognition.face_encodings(picture_of_me)[0]
  4. # my_face_encoding now contains a universal 'encoding' of my facial features that can be compared to any other picture of a face!
  5. unknown_picture = face_recognition.load_image_file("unknown.jpg")
  6. unknown_face_encoding = face_recognition.face_encodings(unknown_picture)[0]
  7. # Now we can see the two face encodings are of the same person with `compare_faces`!
  8. results = face_recognition.compare_faces([my_face_encoding], unknown_face_encoding)
  9. if results[0] == True:
  10. print("It's a picture of me!")
  11. else:
  12. print("It's not a picture of me!")

参考地址:
https://github.com/ageitgey/face_recognition#face-recognition

发表评论

表情:
评论列表 (有 0 条评论,344人围观)

还没有评论,来说两句吧...

相关阅读

    相关 人脸识别python和matlab

    知识背景: 随着社会的不断进步以及各方面对于快速有效的自动身份验证的迫切要求, 生物特征识别技术在近几十年中得到了飞速的发展。 作为人的一种内在属性, 并且具有很强的自