re-enable init delay (#8283)

This commit is contained in:
Nicolas Mowen 2023-10-23 18:50:22 -06:00 committed by GitHub
parent 2fb7200fb7
commit 0b858419d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View File

@ -13,6 +13,7 @@ from frigate.util import intersection_over_union
class CentroidTracker(ObjectTracker):
def __init__(self, config: DetectConfig):
self.tracked_objects = {}
self.untracked_object_boxes = []
self.disappeared = {}
self.positions = {}
self.max_disappeared = config.max_disappeared

View File

@ -1,3 +1,4 @@
import logging
import random
import string
@ -11,6 +12,8 @@ from frigate.track import ObjectTracker
from frigate.types import PTZMetricsTypes
from frigate.util.image import intersection_over_union
logger = logging.getLogger(__name__)
# Normalizes distance from estimate relative to object size
# Other ideas:
@ -62,6 +65,7 @@ class NorfairTracker(ObjectTracker):
ptz_metrics: PTZMetricsTypes,
):
self.tracked_objects = {}
self.untracked_object_boxes: list[list[int]] = []
self.disappeared = {}
self.positions = {}
self.max_disappeared = config.detect.max_disappeared
@ -77,7 +81,7 @@ class NorfairTracker(ObjectTracker):
self.tracker = Tracker(
distance_function=frigate_distance,
distance_threshold=2.5,
initialization_delay=0,
initialization_delay=self.detect_config.fps / 2,
hit_counter_max=self.max_disappeared,
)
if self.ptz_autotracker_enabled.value:
@ -106,11 +110,6 @@ class NorfairTracker(ObjectTracker):
"ymax": self.detect_config.height,
}
# start object with a hit count of `fps` to avoid quick detection -> loss
next(
(o for o in self.tracker.tracked_objects if o.global_id == track_id)
).hit_counter = self.camera_config.detect.fps
def deregister(self, id, track_id):
del self.tracked_objects[id]
del self.disappeared[id]
@ -303,6 +302,12 @@ class NorfairTracker(ObjectTracker):
for e_id in expired_ids:
self.deregister(self.track_id_map[e_id], e_id)
# update list of object boxes that don't have a tracked object yet
tracked_object_boxes = [obj["box"] for obj in self.tracked_objects.values()]
self.untracked_object_boxes = [
o[2] for o in detections if o[2] not in tracked_object_boxes
]
def debug_draw(self, frame, frame_time):
active_detections = [
Drawable(id=obj.id, points=obj.last_detection.points, label=obj.label)

View File

@ -614,14 +614,15 @@ def process_frames(
for obj in object_tracker.tracked_objects.values()
if obj["id"] not in stationary_object_ids
]
object_boxes = tracked_object_boxes + object_tracker.untracked_object_boxes
# get consolidated regions for tracked objects
regions = [
get_cluster_region(
frame_shape, region_min_size, candidate, tracked_object_boxes
frame_shape, region_min_size, candidate, object_boxes
)
for candidate in get_cluster_candidates(
frame_shape, region_min_size, tracked_object_boxes
frame_shape, region_min_size, object_boxes
)
]