python.exe crash if opencv tries to access busy webcam
ifelsetrue at gmail.com
ifelsetrue at gmail.com
Wed Jul 3 09:25:57 EDT 2013
Hello,
I have a while loop taking images every 5 minutes from webcam. Unfortunately, if the camera is busy, python.exe crashes and there is no exception to catch. Is there a way to check if camera is busy to avoid the crash?
Thanks!
from cv2 import *
while True:
time.sleep(4)
cam = VideoCapture(0)
s, img = cam.read()
if s: # frame captured without any errors
namedWindow("cam-test",CV_WINDOW_AUTOSIZE)
imshow("cam-test",img)
waitKey(0)
destroyWindow("cam-test")
imwrite("filename.jpg",img) #save image
More information about the Python-list
mailing list