Add a field to configure inertia per zone

This commit is contained in:
Nick Mowen 2023-06-01 11:11:16 -06:00
parent 4015b5836a
commit cf9538d9ce
3 changed files with 10 additions and 2 deletions

View File

@ -467,6 +467,8 @@ cameras:
# Required: List of x,y coordinates to define the polygon of the zone. # 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. # 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 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) # Optional: List of objects that can trigger this zone (default: all tracked objects)
objects: objects:
- person - person

View File

@ -326,6 +326,12 @@ class ZoneConfig(BaseModel):
coordinates: Union[str, List[str]] = Field( coordinates: Union[str, List[str]] = Field(
title="Coordinates polygon for the defined zone." 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( objects: List[str] = Field(
default_factory=list, default_factory=list,
title="List of objects that can trigger the zone.", title="List of objects that can trigger the zone.",

View File

@ -151,7 +151,7 @@ class TrackedObject:
self.zone_presence[name] = zone_score + 1 self.zone_presence[name] = zone_score + 1
# an object is only considered present in a zone if it has a zone inertia of 3+ # 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 the object passed the filters once, dont apply again
if name in self.current_zones or not zone_filtered(self, zone.filters): if name in self.current_zones or not zone_filtered(self, zone.filters):
current_zones.append(name) current_zones.append(name)
@ -159,7 +159,7 @@ class TrackedObject:
self.entered_zones.append(name) self.entered_zones.append(name)
else: else:
# once an object has a zone inertia of 3+ it is not checked anymore # 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 self.zone_presence[name] = zone_score - 1
if not self.false_positive: if not self.false_positive: