[英]Face verification of given bounding box
我正在使用 face_recognition 的 python 库进行人脸识别演示。
# Grab a single frame of video
ret, frame = video_capture.read()
# Resize frame of video to 1/4 size for faster face recognition processing
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
# Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
rgb_small_frame = small_frame[:, :, ::-1]
# Only process every other frame of video to save time
# Find all the faces and face encodings in the current frame of video
face_locations = face_recognition.face_locations(rgb_small_frame)
上面的代码,据我所知,检测给定框架中不同大小的人脸。 如果我想绘制一个边界框,并且如果该边界框上有一个人脸,那么只有那个人脸应该用于进一步处理。 我的 CPU 不会检测整个帧中不同大小的人脸,而只能从具有固定大小的感兴趣区域检测人脸。
复制图像,将其裁剪为仅边界框,然后在新裁剪的图像上运行人脸识别。
# Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
rgb_small_frame = small_frame[:, :, ::-1]
#crop image based on some bounding box
rgb_cropped = rgb_small_frame[boundy1:boundy2,boundx1,boundx2]
# Only process every other frame of video to save time
# Find all the faces and face encodings in the current frame of video
face_locations = face_recognition.face_locations(rgb_cropped)
你为什么不试试deepface? 它通过一行代码实时应用人脸识别。
#!pip install deepface
from deepface import DeepFace
DeepFace.stream(db_path = "C:/my_db")
在这里,您应该将面部图像数据库存储在 C:/my_db 文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.