python做人脸识别速度_Python人脸识别速度慢

博主在使用Python的face_recognition库进行实时人脸识别时遇到性能问题,特别是处理.mp4视频时fps下降明显。经过调整代码,通过缩小输入图像尺寸并使用探查器定位瓶颈,发现`face_locations`和`face_encodings`函数调用是主要耗时部分。虽然无法直接优化库函数,但博主考虑了使用多处理来提高效率。问题在于如何在代码中实现多处理以利用多核CPU,同时寻求在树莓派上运行时提高速度的方法。
摘要由CSDN通过智能技术生成

我正在尝试构建一个使用面部识别库实时检测面部的软件。 我使用网络摄像头进行了尝试,结果令人鼓舞,帧频也相当稳定,但是当我切换到.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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值