mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 10:45:21 +03:00
Objects need to be in zones multiple times to be considered present in the zone
This commit is contained in:
parent
f0c1b66b0f
commit
4015b5836a
@ -73,6 +73,7 @@ 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.current_zones = []
|
self.current_zones = []
|
||||||
self.entered_zones = []
|
self.entered_zones = []
|
||||||
self.false_positive = True
|
self.false_positive = True
|
||||||
@ -144,13 +145,22 @@ class TrackedObject:
|
|||||||
if len(zone.objects) > 0 and obj_data["label"] not in zone.objects:
|
if len(zone.objects) > 0 and obj_data["label"] not in zone.objects:
|
||||||
continue
|
continue
|
||||||
contour = zone.contour
|
contour = zone.contour
|
||||||
|
zone_score = self.zone_presence.get(name, 0)
|
||||||
# check if the object is in the zone
|
# check if the object is in the zone
|
||||||
if cv2.pointPolygonTest(contour, bottom_center, False) >= 0:
|
if cv2.pointPolygonTest(contour, bottom_center, False) >= 0:
|
||||||
|
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 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)
|
||||||
if name not in self.entered_zones:
|
if name not in self.entered_zones:
|
||||||
self.entered_zones.append(name)
|
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:
|
||||||
|
self.zone_presence[name] = zone_score - 1
|
||||||
|
|
||||||
if not self.false_positive:
|
if not self.false_positive:
|
||||||
# if the zones changed, signal an update
|
# if the zones changed, signal an update
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user