more error resistant

This commit is contained in:
Askill 2019-11-23 12:14:19 +01:00
parent ddb6ead02f
commit 724b977549
1 changed files with 31 additions and 34 deletions

View File

@ -27,6 +27,7 @@ def increase_brightness(img, value=30):
return img
def compare():
try:
url = config.stream
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
@ -49,7 +50,7 @@ def compare():
# loop over the frames of the video
while True:
try:
print(counter)
# grab the current frame and initialize the occupied/unoccupied
# text
frame = vs.read()
@ -59,7 +60,7 @@ def compare():
# if the frame could not be grabbed, then we have reached the end
# of the video
if frame is None:
break
retry("frame was none")
# resize the frame, convert it to grayscale, and blur it
frame = imutils.resize(frame, width=500)
@ -107,20 +108,16 @@ def compare():
com.notify(location)
print(text)
key = cv2.waitKey(1) & 0xFF
counter+=1
if counter % (framerate * delay) == 0:
firstFrame = gray
except Exception as e:
print(e)
retry(e)
# cleanup the camera and close any open windows
#vs.stop() if args.get("video", None) is None else vs.release()
vs.stop() if args.get("video", None) is None else vs.release()
def retry(error):
print(error)
time.sleep(10)
compare()