import cv2import numpy as np# https://github.com/Itseez/opencv/tree/master/data/haarcascadeface_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')videocapture = cv2.VideoCapture(0)scale_factor = 1.3while 1: ret, pic = videocapture.read() faces = face_cascade.detectMultiScale(pic, scale_factor, 5) for(x, y, w, h) in faces: cv2.rectangle(pic, (x, y), (x + w, y + h), (255, 0, 0), 2) font = cv2.FONT_HERSHEY_SIMPLEX cv2.putText(pic, 'Me', (x, y), font, 2, (255, 255, 255), 2, cv2.LINE_AA) print("Number of faces found {} " .format(len(faces))) cv2.imshow('faces', pic) k = cv2.waitKey(30) & 0xff if k == 2: break cv2.destroyAllWindows()[警告:0] 全局 C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-2y91i_7w\opencv\modules\videoio\src\cap_msmf.cpp (435) `anonymous-namespace':: SourceReaderCB::~SourceReaderCB 終止異步回調(diào)
1 回答

蕭十郎
TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超13個(gè)贊
我已經(jīng)得到了此警告的答案,因?yàn)槲也辉试S我的相機(jī)啟動(dòng),所以在允許我的相機(jī)后它已成功運(yùn)行
添加回答
舉報(bào)
0/150
提交
取消