How to fix error error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' when trying to capture a video stream?
I use the simplest code:
import cv2
import time
import numpy as np
cv2.namedWindow("video")
cap = cv2.VideoCapture(1)
time.sleep(3)
while cv2.waitKey(1)!= 30:
flag, frame = cap.read()
cv2.imshow("video", frame)
cap.release()
cv2.destroyAllWindows()
and I have an error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
How can I fix that? Thanks