Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Same problem, my code has been working for a year and now it is not working anymore.

import cv, cv2

vc = cv2.VideoCapture(1)
cv2.namedWindow("video")
vc.set(cv.CV_CAP_PROP_FRAME_WIDTH, 640)
vc.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 480)

while(1):
    ret,frame = vc.read()
    cv2.imshow("video",frame)
    #print len(frame)
    key =  cv2.waitKey(30)

This code was always working, now I get:

python2 play_cam.py 
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /build/opencv/src/opencv-2.4.6/modules/highgui/src/window.cpp, line 269
Traceback (most recent call last):
  File "play_cam.py", line 10, in <module>
    cv2.imshow("video",frame)
cv2.error: /build/opencv/src/opencv-2.4.6/modules/highgui/src/window.cpp:269: error: (-215) size.width>0 && size.height>0 in function imshow