From dd3bfa9e648db79e18d5aee115e3760c1ea2f53a Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 13 Mar 2022 11:33:55 -0400 Subject: [PATCH] Filter objects out of ratio bounds Issue: #2948 --- frigate/object_processing.py | 2 +- frigate/video.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frigate/object_processing.py b/frigate/object_processing.py index ad450a4b9..3742cb7f2 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -346,7 +346,7 @@ def zone_filtered(obj: TrackedObject, object_config): if obj_settings.min_ratio > obj.obj_data["ratio"]: return True - # if the object is not proportionally narrow enough + # if the object is proportionally too wide if obj_settings.max_ratio < obj.obj_data["ratio"]: return True diff --git a/frigate/video.py b/frigate/video.py index 55340d0a1..cea749ec5 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -41,6 +41,7 @@ def filtered(obj, objects_to_track, object_filters): object_score = obj[1] object_box = obj[2] object_area = obj[3] + object_ratio = obj[4] if not object_name in objects_to_track: return True @@ -62,6 +63,14 @@ def filtered(obj, objects_to_track, object_filters): if obj_settings.min_score > object_score: return True + # if the object is not proportionally wide enough + if obj_settings.min_ratio > object_ratio: + return True + + # if the object is proportionally too wide + if obj_settings.max_ratio < object_ratio: + return True + if not obj_settings.mask is None: # compute the coordinates of the object and make sure # the location isn't outside the bounds of the image (can happen from rounding)