Compare commits

...

2 Commits

Author SHA1 Message Date
09201030dd addition of the ability to retry and continue if
camera is disconnected and reconnected
2023-09-23 00:22:23 +03:30
3f19349f53 renamed example files 2023-09-23 00:21:19 +03:30
3 changed files with 11 additions and 2 deletions

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):

View File

@@ -1,7 +1,8 @@
{
"camera_address": "/dev/video1",
"sensitivity_threshold": 0.1,
"sensitivity_threshold": 10,
"api_url": "http://scenesense-server/add_record",
"detection_delay": 5,
"failure_delay": 30,
"api_key": "your_api_key_here"
}