mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 05:05:26 +03:00
simplify
This commit is contained in:
parent
7500b41d41
commit
20d71cc04f
@ -190,24 +190,28 @@ 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)
|
zone_score = self.zone_presence.get(name, 0) + 1
|
||||||
# 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:
|
||||||
# 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):
|
||||||
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 self.zone_presence[name] >= zone.inertia:
|
if zone_score >= zone.inertia:
|
||||||
loitering_score = self.zone_loitering.get(name, 0)
|
loitering_score = self.zone_loitering.get(name, 0) + 1
|
||||||
self.zone_loitering[name] = loitering_score + 1
|
|
||||||
|
|
||||||
# loitering time is configured as seconds, convert to count of frames
|
# 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):
|
if loitering_score >= (
|
||||||
|
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:
|
||||||
self.entered_zones.append(name)
|
self.entered_zones.append(name)
|
||||||
|
else:
|
||||||
|
self.zone_loitering[name] = loitering_score
|
||||||
|
else:
|
||||||
|
self.zone_presence[name] = zone_score
|
||||||
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 < zone.inertia:
|
if 0 < zone_score < zone.inertia:
|
||||||
@ -531,7 +535,9 @@ class CameraState:
|
|||||||
):
|
):
|
||||||
max_target_box = self.ptz_autotracker_thread.ptz_autotracker.tracked_object_metrics[
|
max_target_box = self.ptz_autotracker_thread.ptz_autotracker.tracked_object_metrics[
|
||||||
self.name
|
self.name
|
||||||
]["max_target_box"]
|
][
|
||||||
|
"max_target_box"
|
||||||
|
]
|
||||||
side_length = max_target_box * (
|
side_length = max_target_box * (
|
||||||
max(
|
max(
|
||||||
self.camera_config.detect.width,
|
self.camera_config.detect.width,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user