leafchen

模块:face_recognition

import face_recognitio
官方描述:

face_recognition是一个强大、简单、易上手的人脸识别开源项目,并且配备了完整的开发文档和应用案例,特别是兼容树莓派系统。
本项目是世界上最简洁的人脸识别库,你可以使用Python和命令行工具提取、识别、操作人脸。
本项目的人脸识别是基于业内领先的C++开源库 dlib中的深度学习模型,用Labeled Faces in the Wild人脸数据集进行测试,有高达99.38%的准确率。
但对小孩和亚洲人脸的识别准确率尚待提升。

 依赖项

1. pip install cmake

2. pip install boost

3. pip install dlib

 

简单用法:

import face_recognition
import cv2

# 读取图像数据
image = face_recognition.load_image_file(‘。。。’)

# 获取图像中所有人脸的五官坐标
face_locations = face_recognition.face_landmarks(image)
print(\'face_locations\', face_locations)

# 人脸检测
face_locations = face_recognition.face_locations(image, model="cnn")
y_min, x_max, y_max, x_min = face_locations[0]
cv2.rectangle(image, (x_min, y_min), (x_max, y_max), (0, 0, 255), 2)

# 摄像头五官检测
names = [\'left_eyebrow\', \'right_eyebrow\', \'nose_bridge\', \'nose_tip\', \'top_lip\', \'bottom_lip\', \'left_eye\', \'right_eye\']

cap = cv2.VideoCapture(0)

while True:
    ret, frame = cap.read()
    # 获取图像中所有人脸的五官坐标
    face_locations = face_recognition.face_landmarks(frame)
    
    points = face_locations[0]
    for name in names:
        for point in points[name]:
            cv2.circle(frame, point, 1, (0, 0, 255), -1)

    if cv2.waitKey(1) == 27:
        break
    cv2.imshow(\'Test camera\', frame)

 

分类:

技术点:

相关文章:

  • 2022-01-05
  • 2021-08-01
  • 2021-05-26
  • 2022-01-12
  • 2021-08-15
  • 2021-11-17
  • 2021-07-19
猜你喜欢
  • 2021-10-07
  • 2021-08-06
  • 2021-09-24
  • 2021-04-28
  • 2022-01-04
  • 2021-12-29
  • 2021-12-07
相关资源
相似解决方案