我正在尝试构建一个使用人脸识别库实时检测人脸的软件。我使用网络摄像头进行了尝试,结果令人满意且帧速率相当稳定,但是当我切换到 .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 …Run Code Online (Sandbox Code Playgroud)