make stationary_threshold configurable

This commit is contained in:
Blake Blackshear 2022-02-08 07:40:45 -06:00 committed by Nick Mowen
parent ae3e96d313
commit 83ef8209ca
3 changed files with 9 additions and 4 deletions

View File

@ -199,6 +199,11 @@ class DetectConfig(FrigateBaseModel):
default_factory=StationaryConfig,
title="Stationary objects config.",
)
stationary_threshold: Optional[int] = Field(
default=10,
title="Number of frames without a position change for an object to be considered stationary",
ge=1,
)
class FilterConfig(FrigateBaseModel):

View File

@ -78,9 +78,9 @@ class ObjectTracker:
}
return False
# if there are less than 10 entries for the position, add the bounding box
# if there are less than stationary_threshold entries for the position, add the bounding box
# and recompute the position box
if len(position["xmins"]) < 10:
if len(position["xmins"]) < self.detect_config.stationary_threshold:
position["xmins"].append(xmin)
position["ymins"].append(ymin)
position["xmaxs"].append(xmax)

View File

@ -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 10 frames
if obj["motionless_count"] >= 10
# if there hasn't been motion for N frames
if obj["motionless_count"] >= detect_config.stationary_threshold
# and it isn't due for a periodic check
and (
detect_config.stationary.interval == 0