这年头,能有个开源的人脸库真是感天谢地了,而且可以在arm机器上使用,真不容易。git地址见https://github.com/ageitgey/face_recognition
1. 人脸检测
人脸检测可以选hog和cnn两种。默认用hog(在cpu上用cnn真的很慢)。这个人脸检测对于口罩的识别率不高,慎用。
在使用gpu时,还可以使用批量人脸检测:
face_recognition.batch_face_locations(frames, number_of_times_to_upsample=0)
import cv2
image = face_recognition.load_image_file("....png")
face_locations = face_recognition.face_locations(image,model='cnn')
for r in face_locations:
cv2.rectangle(image,(r[1],r[0]),(r[3],r[2]),(255,0,0),5) # 注意这里的顺序!
io.imshow(image)
说明如下:
Signature:
face_recognition.face_locations(
img,
number_of_times_to_upsample=1,
model='hog',
)
Docstring:
Returns an array of bounding boxes of human faces in a image
:param img: An image (as a numpy array)
:param number_of_times_to_upsample: How many times to upsample the image looking for faces. Higher numbers find smaller faces.
:param model: Which face detection m

该博客介绍了如何利用face_recognition库在ARM设备上进行人脸检测、关键点检测和人脸识别。它强调了库在CPU上使用CNN模型速度较慢,适合在GPU环境下进行批量人脸检测。同时,提到了该库在口罩识别上的不足。通过代码示例展示了如何使用face_recognition进行人脸位置标记和128维面部编码计算。
最低0.47元/天 解锁文章
1850

被折叠的 条评论
为什么被折叠?



