Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow (Python)

Hello!

I searched the Internet but did not find a solution for me. First of all I simply want to run my webcam and see it. Here is my code:

import numpy as np
import cv2

cap = cv2.VideoCapture(3)
print cap.isOpened()
if cap.isOpened():
    print "cap is opened"
    while(True):
        re,img=cap.read()
        cv2.imshow("video output", img)
        k = cv2.waitKey(10)&0xFF
        if k==27:
            break
cap.release()
cv2.destroyAllWindows()

ca.isOpened() still says that it is false, so I do not enter the loop. If I enter the loop without checking then I get the error which I mentioned in the headline. So what am I doing wrong? I try to get my webcam working for 1 hour, its getting a little bit frustrating ;)

Best regards