python opencv 视频人脸识别

python opencv 视频人脸识别,第1张

python opencv 视频人脸识别 It is not right ofthe sun to shine.Everyone can. 发光不是太阳的权利 每个人都可以 关于opencv我就不再多说了上链接

opencv中文http://www.woshicver.com/http://www.woshicver.com/

官网https://opencv.org/https://opencv.org/

1

安装好Python.           pycharm链接https://www.jetbrains.com/zh-cn/pycharm/https://www.jetbrains.com/zh-cn/pycharm/

2安装OpenCV库         下面有   3下载HAAR和LBP特征数据。  (免费https://download.csdn.net/download/qq_53431677/61196677https://download.csdn.net/download/qq_53431677/61196677) opencv库 安装
pip install opencv-python -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com/pypi/simple
 (1)代码
import cv2
import sys
import time
def zcx_jr():
    cameraCapture = cv2.VideoCapture('/Users/chenyutong/documents/pym1/未命名文件夹/video.mp4')#视频地址
    # cv2级联分类器CascadeClassifier,xml文件为训练数据
    face_cascade = cv2.CascadeClassifier('/Users/chenyutong/documents/资源库/opencv/haarcascade_frontalface_default.xml')
    
    success, frame = cameraCapture.read()
    while success and cv2.waitKey(1) == -1:
        ret, img = cameraCapture.read()
        faces = face_cascade.detectMultiScale(img, 1.3, 5)
        for (x, y, w, h) in faces:
            img = cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
        cv2.namedWindow('camera', 0)
        cv2.resizeWindow('camera', 840, 480)
        cv2.imshow('camera', img)
        success, frame = cameraCapture.read()
    cameraCapture.release()
    cv2.destroyAllWindows()
    time.sleep(20)
    sys.exit()
if __name__ == '__main__':
    zcx_jr()
(2)结果展示


以上就是本文所有内容,希望能帮到大家 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5658091.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存