mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
re-enable init delay (#8283)
This commit is contained in:
parent
2fb7200fb7
commit
0b858419d1
@ -13,6 +13,7 @@ from frigate.util import intersection_over_union
|
|||||||
class CentroidTracker(ObjectTracker):
|
class CentroidTracker(ObjectTracker):
|
||||||
def __init__(self, config: DetectConfig):
|
def __init__(self, config: DetectConfig):
|
||||||
self.tracked_objects = {}
|
self.tracked_objects = {}
|
||||||
|
self.untracked_object_boxes = []
|
||||||
self.disappeared = {}
|
self.disappeared = {}
|
||||||
self.positions = {}
|
self.positions = {}
|
||||||
self.max_disappeared = config.max_disappeared
|
self.max_disappeared = config.max_disappeared
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import logging
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
@ -11,6 +12,8 @@ from frigate.track import ObjectTracker
|
|||||||
from frigate.types import PTZMetricsTypes
|
from frigate.types import PTZMetricsTypes
|
||||||
from frigate.util.image import intersection_over_union
|
from frigate.util.image import intersection_over_union
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# Normalizes distance from estimate relative to object size
|
# Normalizes distance from estimate relative to object size
|
||||||
# Other ideas:
|
# Other ideas:
|
||||||
@ -62,6 +65,7 @@ class NorfairTracker(ObjectTracker):
|
|||||||
ptz_metrics: PTZMetricsTypes,
|
ptz_metrics: PTZMetricsTypes,
|
||||||
):
|
):
|
||||||
self.tracked_objects = {}
|
self.tracked_objects = {}
|
||||||
|
self.untracked_object_boxes: list[list[int]] = []
|
||||||
self.disappeared = {}
|
self.disappeared = {}
|
||||||
self.positions = {}
|
self.positions = {}
|
||||||
self.max_disappeared = config.detect.max_disappeared
|
self.max_disappeared = config.detect.max_disappeared
|
||||||
@ -77,7 +81,7 @@ class NorfairTracker(ObjectTracker):
|
|||||||
self.tracker = Tracker(
|
self.tracker = Tracker(
|
||||||
distance_function=frigate_distance,
|
distance_function=frigate_distance,
|
||||||
distance_threshold=2.5,
|
distance_threshold=2.5,
|
||||||
initialization_delay=0,
|
initialization_delay=self.detect_config.fps / 2,
|
||||||
hit_counter_max=self.max_disappeared,
|
hit_counter_max=self.max_disappeared,
|
||||||
)
|
)
|
||||||
if self.ptz_autotracker_enabled.value:
|
if self.ptz_autotracker_enabled.value:
|
||||||
@ -106,11 +110,6 @@ class NorfairTracker(ObjectTracker):
|
|||||||
"ymax": self.detect_config.height,
|
"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):
|
def deregister(self, id, track_id):
|
||||||
del self.tracked_objects[id]
|
del self.tracked_objects[id]
|
||||||
del self.disappeared[id]
|
del self.disappeared[id]
|
||||||
@ -303,6 +302,12 @@ class NorfairTracker(ObjectTracker):
|
|||||||
for e_id in expired_ids:
|
for e_id in expired_ids:
|
||||||
self.deregister(self.track_id_map[e_id], e_id)
|
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):
|
def debug_draw(self, frame, frame_time):
|
||||||
active_detections = [
|
active_detections = [
|
||||||
Drawable(id=obj.id, points=obj.last_detection.points, label=obj.label)
|
Drawable(id=obj.id, points=obj.last_detection.points, label=obj.label)
|
||||||
|
@ -614,14 +614,15 @@ def process_frames(
|
|||||||
for obj in object_tracker.tracked_objects.values()
|
for obj in object_tracker.tracked_objects.values()
|
||||||
if obj["id"] not in stationary_object_ids
|
if obj["id"] not in stationary_object_ids
|
||||||
]
|
]
|
||||||
|
object_boxes = tracked_object_boxes + object_tracker.untracked_object_boxes
|
||||||
|
|
||||||
# get consolidated regions for tracked objects
|
# get consolidated regions for tracked objects
|
||||||
regions = [
|
regions = [
|
||||||
get_cluster_region(
|
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(
|
for candidate in get_cluster_candidates(
|
||||||
frame_shape, region_min_size, tracked_object_boxes
|
frame_shape, region_min_size, object_boxes
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user