Catch case where images do not exist

This commit is contained in:
Nicolas Mowen 2024-07-08 16:30:05 -06:00
parent de9160ccaa
commit 42be7efde4
4 changed files with 21 additions and 9 deletions

View File

@ -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}"
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())

View File

@ -94,7 +94,11 @@ def output_frames(
frame_id = f"{camera}{frame_time}"
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(

View File

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

View File

@ -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
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.")