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/
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)结果展示
以上就是本文所有内容,希望能帮到大家