运行此代码时出现错误
if not faceFound:
if lastface == 0 or lastface == 1:
aframe = webcam.read()[1] # there seems to be an issue in OpenCV or V4L or my webcam-
aframe = webcam.read()[1] # driver, I'm not sure which, but if you wait too long,
aframe = webcam.read()[1] # the webcam consistantly gets exactly five frames behind-
aframe = webcam.read()[1] # realtime. So we just grab a frame five times to ensure-
aframe = webcam.read()[1]
fface = frontalface.detectMultiScale(aframe,1.3,4,(cv2.cv.CV_HAAR_DO_CANNY_PRUNING + cv2.cv.CV_HAAR_FIND_BIGGEST_OBJECT + cv2.cv.CV_HAAR_DO_ROUGH_SEARCH),(60,60))
if fface != ():
lastface = 1
for f in fface:
faceFound = True
face = f
i got this error
AttributeError:模块'cv2'没有属性'cv。CV_HAAR_DO_CANNY_PRUNING '
我试图安装'pip install opencv-python'
修改如下:
fface = frontalface.detectMultiScale(aframe,1.3,4,(cv2.cv.CV_HAAR_DO_CANNY_PRUNING + cv2.cv.CV_HAAR_FIND_BIGGEST_OBJECT + cv2.cv.CV_HAAR_DO_ROUGH_SEARCH),(60,60))
:
fface = frontalface.detectMultiScale(aframe,1.3,4,(cv2.CV_HAAR_DO_CANNY_PRUNING + cv2.CV_HAAR_FIND_BIGGEST_OBJECT + cv2.CV_HAAR_DO_ROUGH_SEARCH),(60,60))