Configure loitering

This commit is contained in:
Nicolas Mowen 2024-03-19 13:43:50 -06:00
parent a767e768a0
commit 7500b41d41

View File

@ -116,7 +116,8 @@ class TrackedObject:
self.colormap = colormap self.colormap = colormap
self.camera_config = camera_config self.camera_config = camera_config
self.frame_cache = frame_cache self.frame_cache = frame_cache
self.zone_presence = {} self.zone_presence: dict[str, int] = {}
self.zone_loitering: dict[str, int] = {}
self.current_zones = [] self.current_zones = []
self.entered_zones = [] self.entered_zones = []
self.attributes = defaultdict(float) self.attributes = defaultdict(float)
@ -198,6 +199,11 @@ class TrackedObject:
# 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 self.zone_presence[name] >= zone.inertia: if self.zone_presence[name] >= zone.inertia:
loitering_score = self.zone_loitering.get(name, 0)
self.zone_loitering[name] = loitering_score + 1
# loitering time is configured as seconds, convert to count of frames
if self.zone_loitering[name] >= (self.camera_config.zones[name].loitering_time * self.camera_config.detect.fps):
current_zones.append(name) current_zones.append(name)
if name not in self.entered_zones: if name not in self.entered_zones: