i try to open my webcam using openCV, i've tried lots of ways but still get error:
import cv2
framWidth = 640
framHeight = 580
cap = cv2.VideoCapture(1)
cap.set(3, framWidth)
cap.set(4, framHeight)
cap.set(10, 150)
while True:
success, img = cap.read()
cv2.imshow('Result', img)
if cv2.waitkey(1) & 0xFF == ord('q'):
break
and here is the error:
cv2.error: OpenCV(4.6.0) /io/opencv/modules/highgui/src/window.cpp:967: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow
i tried VideoCapture(0) but the same error. i saw many common questions like that, but they did not solve my problem. these is the most simple way to open webcam