From cf9538d9ce5058ec901b8d8ce352badfaf68cdb0 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 1 Jun 2023 11:11:16 -0600 Subject: [PATCH] Add a field to configure inertia per zone --- docs/docs/configuration/index.md | 2 ++ frigate/config.py | 6 ++++++ frigate/object_processing.py | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 0a1b230aa..c2ee60c1d 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -467,6 +467,8 @@ cameras: # Required: List of x,y coordinates to define the polygon of the zone. # NOTE: Presence in a zone is evaluated only based on the bottom center of the objects bounding box. coordinates: 545,1077,747,939,788,805 + # Optional: Set the inertia required for an object to be considered present in the zone. Allowed values are 0 < inertia < 10 (default: shown below) + inertia: 3 # Optional: List of objects that can trigger this zone (default: all tracked objects) objects: - person diff --git a/frigate/config.py b/frigate/config.py index 5c2f27b5a..f2e0b7d59 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -326,6 +326,12 @@ class ZoneConfig(BaseModel): coordinates: Union[str, List[str]] = Field( title="Coordinates polygon for the defined zone." ) + inertia: int = Field( + default_factory=3, + title="Number of frames required for object to be considered present in the zone.", + gt=0, + le=10, + ) objects: List[str] = Field( default_factory=list, title="List of objects that can trigger the zone.", diff --git a/frigate/object_processing.py b/frigate/object_processing.py index ca210e6db..c8cbe7245 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -151,7 +151,7 @@ class TrackedObject: self.zone_presence[name] = zone_score + 1 # an object is only considered present in a zone if it has a zone inertia of 3+ - if zone_score >= 3: + if zone_score >= zone.inertia: # if the object passed the filters once, dont apply again if name in self.current_zones or not zone_filtered(self, zone.filters): current_zones.append(name) @@ -159,7 +159,7 @@ class TrackedObject: self.entered_zones.append(name) else: # once an object has a zone inertia of 3+ it is not checked anymore - if 0 < zone_score < 3: + if 0 < zone_score < zone.inertia: self.zone_presence[name] = zone_score - 1 if not self.false_positive: