From 7934f8699f5d227cbe27f57594e864372a113172 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 11 Feb 2022 06:54:42 -0600 Subject: [PATCH 1/4] fix the bounding box calculation position at 10 --- frigate/objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frigate/objects.py b/frigate/objects.py index 1711ed4f4..7adf421d9 100644 --- a/frigate/objects.py +++ b/frigate/objects.py @@ -78,9 +78,9 @@ class ObjectTracker: } return False - # if there are less than stationary_threshold entries for the position, add the bounding box + # if there are less than 10 entries for the position, add the bounding box # and recompute the position box - if len(position["xmins"]) < self.detect_config.stationary_threshold: + if len(position["xmins"]) < 10: position["xmins"].append(xmin) position["ymins"].append(ymin) position["xmaxs"].append(xmax) From 4e52461aa9c33560db31dcec8ad4f547b1776a6d Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 11 Feb 2022 07:12:51 -0600 Subject: [PATCH 2/4] set stationary_threshold default to 5x fps --- docs/docs/configuration/index.md | 4 ++-- frigate/config.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 80eb3fef8..25c85741f 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -162,8 +162,8 @@ detect: # Optional: Frequency for running detection on stationary objects (default: shown below) # When set to 0, object detection will never be run on stationary objects. If set to 10, it will be run on every 10th frame. stationary_interval: 0 - # Optional: Number of frames without a position change for an object to be considered stationary (default: shown below) - stationary_threshold: 10 + # Optional: Number of frames without a position change for an object to be considered stationary (default: 5x the frame rate) + stationary_threshold: 25 # Optional: Object configuration # NOTE: Can be overridden at the camera level diff --git a/frigate/config.py b/frigate/config.py index f7f82e91d..a5f5275a2 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -178,7 +178,6 @@ class DetectConfig(FrigateBaseModel): ge=0, ) stationary_threshold: Optional[int] = Field( - default=10, title="Number of frames without a position change for an object to be considered stationary", ge=1, ) @@ -771,6 +770,11 @@ class FrigateConfig(FrigateBaseModel): if camera_config.detect.max_disappeared is None: camera_config.detect.max_disappeared = max_disappeared + # Default stationary_threshold configuration + stationary_threshold = camera_config.detect.fps * 5 + if camera_config.detect.stationary_threshold is None: + camera_config.detect.stationary_threshold = stationary_threshold + # FFMPEG input substitution for input in camera_config.ffmpeg.inputs: input.path = input.path.format(**FRIGATE_ENV_VARS) From 95ab22d4111f4d09feab2e1a65566896615a4d46 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 11 Feb 2022 07:30:47 -0600 Subject: [PATCH 3/4] bump default stationary_threshold to 10s --- docs/docs/configuration/index.md | 4 ++-- frigate/config.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 25c85741f..a929d8363 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -162,8 +162,8 @@ detect: # Optional: Frequency for running detection on stationary objects (default: shown below) # When set to 0, object detection will never be run on stationary objects. If set to 10, it will be run on every 10th frame. stationary_interval: 0 - # Optional: Number of frames without a position change for an object to be considered stationary (default: 5x the frame rate) - stationary_threshold: 25 + # Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s) + stationary_threshold: 50 # Optional: Object configuration # NOTE: Can be overridden at the camera level diff --git a/frigate/config.py b/frigate/config.py index a5f5275a2..3bfda8c55 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -771,7 +771,7 @@ class FrigateConfig(FrigateBaseModel): camera_config.detect.max_disappeared = max_disappeared # Default stationary_threshold configuration - stationary_threshold = camera_config.detect.fps * 5 + stationary_threshold = camera_config.detect.fps * 10 if camera_config.detect.stationary_threshold is None: camera_config.detect.stationary_threshold = stationary_threshold From 6b2bae040c6e80cbb3e4fbc15b62fc59ea5a7609 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 11 Feb 2022 07:34:42 -0600 Subject: [PATCH 4/4] stop forcing detection all the way to stationary_threshold --- frigate/video.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frigate/video.py b/frigate/video.py index 2d419cc1d..cb201fd22 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -507,8 +507,8 @@ def process_frames( stationary_object_ids = [ obj["id"] for obj in object_tracker.tracked_objects.values() - # if there hasn't been motion for N frames - if obj["motionless_count"] >= detect_config.stationary_threshold + # if there hasn't been motion for 10 frames + if obj["motionless_count"] >= 10 # and it isn't due for a periodic check and ( detect_config.stationary_interval == 0