From ae532a465bfca8e3161daabb609ad7e5ba720e3a Mon Sep 17 00:00:00 2001 From: supercoder-dev Date: Wed, 12 Jun 2024 15:25:33 +0530 Subject: [PATCH] Update birdseye.py --- frigate/output/birdseye.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frigate/output/birdseye.py b/frigate/output/birdseye.py index 2b17a4cf1..6559d5f94 100644 --- a/frigate/output/birdseye.py +++ b/frigate/output/birdseye.py @@ -282,9 +282,11 @@ class BirdsEyeFrameManager: self.canvas = Canvas(width, height, config.birdseye.layout.scaling_factor) self.stop_event = stop_event self.inactivity_threshold = config.birdseye.inactivity_threshold + self.min_display_duration = config.birdseye.min_display_duration # New parameter if config.birdseye.layout.max_cameras: self.last_refresh_time = 0 + self.last_camera_switch_time = 0 # Track the last switch time # initialize the frame as black and with the Frigate logo self.blank_frame = np.zeros(self.yuv_shape, np.uint8) @@ -403,9 +405,9 @@ class BirdsEyeFrameManager: max_cameras = self.config.birdseye.layout.max_cameras max_camera_refresh = False - if max_cameras: - now = datetime.datetime.now().timestamp() + now = datetime.datetime.now().timestamp() + if max_cameras: if len(active_cameras) == max_cameras and now - self.last_refresh_time < 10: # don't refresh cameras too often active_cameras = self.active_cameras @@ -446,11 +448,16 @@ class BirdsEyeFrameManager: else: reset_layout = True + # Ensure the current camera has been displayed for at least min_display_duration seconds + if len(self.active_cameras) == 1 and now - self.last_camera_switch_time < self.min_display_duration: + reset_layout = False + # reset the layout if it needs to be different if reset_layout: logger.debug("Added new cameras, resetting layout...") self.clear_frame() self.active_cameras = active_cameras + self.last_camera_switch_time = now # Update the last switch time # this also converts added_cameras from a set to a list since we need # to pop elements in order