Skip to content Skip to sidebar Skip to footer

How To Solve "cv2. error: (-215) size.width>0 && size.height>0 in function imshow" Error In Python?

This is the code I am using for capturing video through my webcam: import cv2 cap = cv2.VideoCapture(0) while True: ret, frame= cap.read() # frame= cv2.resize(frame, None,

Solution 1:

imshow fails when you pass an empty image, as pointed out by @101. In your case, this is most likely due to the fact that you ignore empty frames from cap.read() and call imshow even if cap.read returned an empty image.

To fix this, replace your while True loop with a while cap.isOpened() or check whether cap.isOpened() has been successful before reading frames.

Post a Comment for "How To Solve "cv2. error: (-215) size.width>0 && size.height>0 in function imshow" Error In Python?"