1 | initial version |
python users NEVER do any nessecary checks, so they get those errors.
your videocapture did not open, or it could not retrieve a frame.
cam=cv2.VideoCapture(1); # try 0 here instead
if not cap.isOpened():
print("no capture!")
return
while(True):
retval,img=cam.read();
if retval == False:
print("no capture!")
return
again, you HAVE TO check the outcome of reading resources, opening streams, etc. (same for cv2.imread() or similar)
if you have only a single webcam attached to your box, the only valid camera id would be 0, not 1.
2 | No.2 Revision |
python users NEVER do any nessecary checks, so they get those errors.
your videocapture did not open, or it could not retrieve a frame.
cam=cv2.VideoCapture(1); # try 0 here instead
if not cap.isOpened():
print("no capture!")
return
while(True):
retval,img=cam.read();
if retval == False:
print("no capture!")
image!")
return
again, you HAVE TO check the outcome of reading resources, opening streams, etc. (same for cv2.imread() or similar)
if you have only a single webcam attached to your box, the only valid camera id would be 0, not 1.