Adjust loitering behavior based on object type (#19433)

* Adjust loitering behavior based on object

* Update docs

* Grammar
This commit is contained in:
Nicolas Mowen 2025-08-08 08:14:59 -06:00 committed by GitHub
parent c75d30d902
commit 9b2f84d3e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 3 deletions

View File

@ -88,7 +88,9 @@ Sometimes objects are expected to be passing through a zone, but an object loite
:::note
When using loitering zones, a review item will remain active until the object leaves. Loitering zones are only meant to be used in areas where loitering is not expected behavior.
When using loitering zones, a review item will behave in the following way:
- When a person is in a loitering zone, the review item will remain active until the person leaves the loitering zone, regardless of if they are stationary.
- When any other object is in a loitering zone, the review item will remain active until the loitering time is met. Then if the object is stationary the review item will end.
:::

View File

@ -32,6 +32,14 @@ from frigate.util.velocity import calculate_real_world_speed
logger = logging.getLogger(__name__)
# In most cases objects that loiter in a loitering zone should alert,
# but can still be expected to stay stationary for extended periods of time
# (ex: car loitering on the street vs when a known person parks on the street)
# person is the main object that should keep alerts going as long as they loiter
# even if they are stationary.
EXTENDED_LOITERING_OBJECTS = ["person"]
class TrackedObject:
def __init__(
self,
@ -247,8 +255,12 @@ class TrackedObject:
if zone.distances and not in_speed_zone:
continue # Skip zone entry for speed zones until speed threshold met
# if the zone has loitering time, update loitering status
if zone.loitering_time > 0:
# if the zone has loitering time, and the object is an extended loiter object
# always mark it as loitering actively
if (
self.obj_data["label"] in EXTENDED_LOITERING_OBJECTS
and zone.loitering_time > 0
):
in_loitering_zone = True
loitering_score = self.zone_loitering.get(name, 0) + 1
@ -264,6 +276,10 @@ class TrackedObject:
self.entered_zones.append(name)
else:
self.zone_loitering[name] = loitering_score
# this object is pending loitering but has not entered the zone yet
if zone.loitering_time > 0:
in_loitering_zone = True
else:
self.zone_presence[name] = zone_score
else: