Ask Your Question

potu1304's profile - activity

2019-02-12 15:05:11 -0600 received badge  Famous Question (source)
2018-08-08 20:27:46 -0600 received badge  Notable Question (source)
2018-01-05 04:50:14 -0600 received badge  Popular Question (source)
2017-03-30 04:20:25 -0600 commented question OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow (Python)

I have the one from the notebook self, and would like to use the one I plugged in. So I thought id = 1 but it also does not work

2017-03-29 10:19:10 -0600 asked a question 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