From 42be7efde47bcec5f7336b293ff409152358104d Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 8 Jul 2024 16:30:05 -0600 Subject: [PATCH] Catch case where images do not exist --- frigate/object_processing.py | 11 ++++++++--- frigate/output/output.py | 6 +++++- frigate/util/image.py | 2 ++ frigate/video.py | 11 ++++++----- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 7ac0b7276..f9c513d6b 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -659,9 +659,14 @@ class CameraState: def update(self, frame_time, current_detections, motion_boxes, regions): # get the new frame frame_id = f"{self.name}{frame_time}" - current_frame = self.frame_manager.get( - frame_id, self.camera_config.frame_shape_yuv - ) + + try: + current_frame = self.frame_manager.get( + frame_id, self.camera_config.frame_shape_yuv + ) + except FileNotFoundError: + logger.error(f"Failed to get {frame_id} from SHM") + return tracked_objects = self.tracked_objects.copy() current_ids = set(current_detections.keys()) diff --git a/frigate/output/output.py b/frigate/output/output.py index d0fd43068..d932d88d3 100644 --- a/frigate/output/output.py +++ b/frigate/output/output.py @@ -94,7 +94,11 @@ def output_frames( frame_id = f"{camera}{frame_time}" - frame = frame_manager.get(frame_id, config.cameras[camera].frame_shape_yuv) + try: + frame = frame_manager.get(frame_id, config.cameras[camera].frame_shape_yuv) + except FileNotFoundError: + logger.error(f"Failed to get {frame_id} from SHM") + continue # send camera frame to ffmpeg process if websockets are connected if any( diff --git a/frigate/util/image.py b/frigate/util/image.py index 3962d9600..4f5f40515 100644 --- a/frigate/util/image.py +++ b/frigate/util/image.py @@ -712,6 +712,8 @@ class SharedMemoryFrameManager(FrameManager): self.shm_store[name].close() self.shm_store[name].unlink() del self.shm_store[name] + else: + logger.error(f"Could not delete {name} the store is {self.shm_store}") def create_mask(frame_shape, mask): diff --git a/frigate/video.py b/frigate/video.py index 69a65bfa0..3ab060826 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -147,8 +147,6 @@ def capture_frames( try: # add to the queue frame_queue.put(current_frame.value, False) - # close the frame - frame_manager.close(frame_name) except queue.Full: # if the queue is full, skip this frame skipped_eps.update() @@ -572,9 +570,12 @@ def process_frames( current_frame_time.value = frame_time ptz_metrics["ptz_frame_time"].value = frame_time - frame = frame_manager.get( - f"{camera_name}{frame_time}", (frame_shape[0] * 3 // 2, frame_shape[1]) - ) + try: + frame = frame_manager.get( + f"{camera_name}{frame_time}", (frame_shape[0] * 3 // 2, frame_shape[1]) + ) + except FileNotFoundError: + frame = None if frame is None: logger.info(f"{camera_name}: frame {frame_time} is not in memory store.")