From 2b2c831253e0fa8c2fc518bf2990f64245cdb476 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 6 Nov 2023 05:45:37 -0700 Subject: [PATCH] Set the min region size as the model size (#8486) --- frigate/app.py | 4 +++- frigate/comms/dispatcher.py | 6 +++++- frigate/util/object.py | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index 554d88277..c5357e400 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -487,7 +487,9 @@ class FrigateApp: # create or update region grids for each camera for camera in self.config.cameras.values(): self.region_grids[camera.name] = get_camera_regions_grid( - camera.name, camera.detect + camera.name, + camera.detect, + max(self.config.model.width, self.config.model.height), ) def start_camera_processors(self) -> None: diff --git a/frigate/comms/dispatcher.py b/frigate/comms/dispatcher.py index bcef9a2fb..b7bdb86fa 100644 --- a/frigate/comms/dispatcher.py +++ b/frigate/comms/dispatcher.py @@ -96,7 +96,11 @@ class Dispatcher: elif topic == REQUEST_REGION_GRID: camera = payload self.camera_metrics[camera]["region_grid_queue"].put( - get_camera_regions_grid(camera, self.config.cameras[camera].detect) + get_camera_regions_grid( + camera, + self.config.cameras[camera].detect, + max(self.config.model.width, self.config.model.height), + ) ) else: self.publish(topic, payload, retain=False) diff --git a/frigate/util/object.py b/frigate/util/object.py index 9605e8ab4..0bf7ea179 100644 --- a/frigate/util/object.py +++ b/frigate/util/object.py @@ -30,7 +30,9 @@ GRID_SIZE = 8 def get_camera_regions_grid( - name: str, detect: DetectConfig + name: str, + detect: DetectConfig, + min_region_size: int, ) -> list[list[dict[str, any]]]: """Build a grid of expected region sizes for a camera.""" # get grid from db if available @@ -99,7 +101,7 @@ def get_camera_regions_grid( box[1] * height, (box[0] + box[2]) * width, (box[1] + box[3]) * height, - 320, + min_region_size, 1.35, ) # save width of region to grid as relative