У меня есть вот такой код
import numpy as np
import cv2
import time
faceCascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
cap = cv2.VideoCapture(1)
cap.set(3,640)
cap.set(4,480)
while True:
ret, img = cap.read()
faces = faceCascade.detectMultiScale(
scaleFactor = 1.2,
minNeighbors = 5,
minSize = (50,50)
)
for (x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
roi_color = img[y:y+h, x:x+w]
cv2.imshow('video',img)
k = cv2.waitKey(30) & 0xff
if k == 27: # нажми 'ESC' для выхода
break
cap.release()
cv2.destroyAllWindows()
Он мне выдает ошибку:
VIDEOIO ERROR: V4L: can't open camera by index 1
Traceback (most recent call last):
File "OpenCV.py", line 16, in <module>
minSize = (50,50)
TypeError: Required argument 'image' (pos 1) not found