我正在尝试构建一个使用面部识别库实时检测面部的软件。 我使用网络摄像头进行了尝试,结果令人鼓舞,帧频也相当稳定,但是当我切换到.mp4视频时,在fps方面效果非常差。 我在OpenCV中使用Python 3.6,这是我正在使用的代码:
import face_recognition
import cv2
# Load a sample picture and learn how to recognize it.
totti_image = face_recognition.load_image_file("totti.jpg")
totti_face_encoding = face_recognition.face_encodings(totti_image)[0]
# Create arrays of known face encodings and their names
known_face_encodings = [
totti_face_encoding
]
known_face_names = [
"Francesco Totti"
]
def get_faces(frame):
# Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
rgb_frame = frame[:, :, ::-1]
# Find all the faces and face enqcodings in the frame of video
face_locations = face_recognition.f