From 08b4c8ad2ad755fbbecb7302601d5bf7b323b636 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 16 Jun 2023 05:53:50 -0500 Subject: [PATCH] require a stationary interval --- docs/docs/configuration/index.md | 6 +++--- docs/docs/configuration/stationary_objects.md | 6 +++--- frigate/config.py | 14 +++++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 94eec0a90..b66ff15f5 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -206,10 +206,10 @@ detect: max_disappeared: 25 # Optional: Configuration for stationary object tracking stationary: - # Optional: Frequency for confirming stationary objects (default: shown below) - # When set to 0, object detection will not confirm stationary objects until movement is detected. + # Optional: Frequency for confirming stationary objects (default: same as threshold) + # When set to 1, object detection will run to confirm the object still exists on every frame. # If set to 10, object detection will run to confirm the object still exists on every 10th frame. - interval: 0 + interval: 50 # Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s) threshold: 50 # Optional: Define a maximum number of frames for tracking a stationary object (default: not set, track forever) diff --git a/docs/docs/configuration/stationary_objects.md b/docs/docs/configuration/stationary_objects.md index deeee9ffd..530c41aa4 100644 --- a/docs/docs/configuration/stationary_objects.md +++ b/docs/docs/configuration/stationary_objects.md @@ -1,6 +1,6 @@ # Stationary Objects -An object is considered stationary when it is being tracked and has been in a very similar position for a certain number of frames. This number is defined in the configuration under `detect -> stationary -> threshold`, and is 10x the frame rate (or 10 seconds) by default. Once an object is considered stationary, it will remain stationary until motion occurs near the object at which point object detection will start running again. If the object changes location, it will be considered active. +An object is considered stationary when it is being tracked and has been in a very similar position for a certain number of frames. This number is defined in the configuration under `detect -> stationary -> threshold`, and is 10x the frame rate (or 10 seconds) by default. Once an object is considered stationary, it will remain stationary until motion occurs within the object at which point object detection will start running again. If the object changes location, it will be considered active. ## Why does it matter if an object is stationary? @@ -13,11 +13,11 @@ The default config is: ```yaml detect: stationary: - interval: 0 + interval: 50 threshold: 50 ``` -`interval` is defined as the frequency for running detection on stationary objects. This means that by default once an object is considered stationary, detection will not be run on it until motion is detected. With `interval > 0`, every nth frames detection will be run to make sure the object is still there. +`interval` is defined as the frequency for running detection on stationary objects. This means that by default once an object is considered stationary, detection will not be run on it until motion is detected or until the interval (every 50th frame by default). With `interval >= 1`, every nth frames detection will be run to make sure the object is still there. NOTE: There is no way to disable stationary object tracking with this value. diff --git a/frigate/config.py b/frigate/config.py index cb9d1f602..f21d49d1a 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -13,9 +13,11 @@ from pydantic.fields import PrivateAttr from frigate.const import CACHE_DIR, DEFAULT_DB_PATH, REGEX_CAMERA_NAME, YAML_EXT from frigate.detectors import DetectorConfig, ModelConfig -from frigate.detectors.detector_config import InputTensorEnum # noqa: F401 -from frigate.detectors.detector_config import PixelFormatEnum # noqa: F401 -from frigate.detectors.detector_config import BaseDetectorConfig +from frigate.detectors.detector_config import ( + BaseDetectorConfig, + InputTensorEnum, # noqa: F401 + PixelFormatEnum, # noqa: F401 +) from frigate.ffmpeg_presets import ( parse_preset_hardware_acceleration_decode, parse_preset_hardware_acceleration_scale, @@ -251,9 +253,8 @@ class StationaryMaxFramesConfig(FrigateBaseModel): class StationaryConfig(FrigateBaseModel): interval: Optional[int] = Field( - default=0, title="Frame interval for checking stationary objects.", - ge=0, + gt=0, ) threshold: Optional[int] = Field( title="Number of frames without a position change for an object to be considered stationary", @@ -963,6 +964,9 @@ class FrigateConfig(FrigateBaseModel): stationary_threshold = camera_config.detect.fps * 10 if camera_config.detect.stationary.threshold is None: camera_config.detect.stationary.threshold = stationary_threshold + # default to the stationary_threshold if not defined + if camera_config.detect.stationary.interval is None: + camera_config.detect.stationary.interval = stationary_threshold # FFMPEG input substitution for input in camera_config.ffmpeg.inputs: