addition of the ability to retry and continue if

camera is disconnected and reconnected
This commit is contained in:
2023-09-23 00:22:23 +03:30
parent 3f19349f53
commit 09201030dd

View File

@@ -97,7 +97,15 @@ class CameraMonitor:
ret, current_frame = self.capture.read()
if not ret:
raise Exception("Failed to read frame")
self.logger.error("Failed to read frame")
delay = self.config['failure_delay']
self.logger.info(f"Will retry after {delay} seconds")
self.capture.release()
time.sleep(delay)
self.logger.info("Retrying")
self.capture = self.initialize_camera()
continue
if previous_frame is not None:
if self.detect_scene_change(previous_frame, current_frame):