addition of the ability to retry and continue if
camera is disconnected and reconnected
This commit is contained in:
@@ -97,7 +97,15 @@ class CameraMonitor:
|
|||||||
ret, current_frame = self.capture.read()
|
ret, current_frame = self.capture.read()
|
||||||
|
|
||||||
if not ret:
|
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 previous_frame is not None:
|
||||||
if self.detect_scene_change(previous_frame, current_frame):
|
if self.detect_scene_change(previous_frame, current_frame):
|
||||||
|
|||||||
Reference in New Issue
Block a user