-from collections import OrderedDict
-import numpy as np
-from scipy.spatial import distance
-from scipy.optimize import linear_sum_assignment
-from motrackers.tracker import Tracker
-from motrackers.track import KFTrackCentroid
-from motrackers.utils.misc import get_centroid
-
-
-[docs]def assign_tracks2detection_centroid_distances(bbox_tracks, bbox_detections, distance_threshold=10.):
-
"""
+
from collections import OrderedDict
+
import numpy as np
+
from scipy.spatial import distance
+
from scipy.optimize import linear_sum_assignment
+
from motrackers.tracker import Tracker
+
from motrackers.track import KFTrackCentroid
+
from motrackers.utils.misc import get_centroid
+
+
+
+
[docs]
+
def assign_tracks2detection_centroid_distances(bbox_tracks, bbox_detections, distance_threshold=10.):
+
"""
Assigns detected bounding boxes to tracked bounding boxes using IoU as a distance metric.
Args:
@@ -186,11 +105,10 @@
Source code for motrackers.centroid_kf_tracker
Returns:
tuple: Tuple containing the following elements:
- - matches (numpy.ndarray): Array of shape `(n, 2)` where `n` is number of pairs formed after
- matching tracks to detections. This is an array of tuples with each element as matched pair
- of indices`(track_index, detection_index)`.
+ - matches (numpy.ndarray): Array of shape `(n, 2)` where `n` is number of pairs formed after matching tracks to detections. This is an array of tuples with each element as matched pair of indices`(track_index, detection_index)`.
- unmatched_detections (numpy.ndarray): Array of shape `(m,)` where `m` is number of unmatched detections.
- unmatched_tracks (numpy.ndarray): Array of shape `(k,)` where `k` is the number of unmatched tracks.
+
"""
if (bbox_tracks.size == 0) or (bbox_detections.size == 0):
@@ -235,8 +153,11 @@
Source code for motrackers.centroid_kf_tracker
return matches, np.array(unmatched_detections), np.array(unmatched_tracks)
-
[docs]class CentroidKF_Tracker(Tracker):
-
"""
+
+
+
[docs]
+
class CentroidKF_Tracker(Tracker):
+
"""
Kalman filter based tracking of multiple detected objects.
Args:
@@ -249,7 +170,7 @@
Source code for motrackers.centroid_kf_tracker
time_step (int or float): Time step for Kalman Filter.
"""
- def __init__(
+ def __init__(
self,
max_lost=1,
centroid_distance_threshold=30.,
@@ -265,7 +186,7 @@
Source code for motrackers.centroid_kf_tracker
self.kalman_trackers = OrderedDict()
super().__init__(max_lost, tracker_output_format)
- def _add_track(self, frame_id, bbox, detection_confidence, class_id, **kwargs):
+ def _add_track(self, frame_id, bbox, detection_confidence, class_id, **kwargs):
self.tracks[self.next_track_id] = KFTrackCentroid(
self.next_track_id, frame_id, bbox, detection_confidence, class_id=class_id,
data_output_format=self.tracker_output_format, process_noise_scale=self.process_noise_scale,
@@ -273,7 +194,24 @@
Source code for motrackers.centroid_kf_tracker
)
self.next_track_id += 1
-
[docs] def update(self, bboxes, detection_scores, class_ids):
+
def _assign(self, bbox_tracks, bbox_detections):
+
"""
+
Associate tracked bounding boxes with detected bounding boxes.
+
+
Args:
+
bbox_tracks (numpy.ndarray): Predicted bounding boxes of tracks with shape `(n, 4)`.
+
bbox_detections (numpy.ndarray): Detected bounding boxes with shape `(m, 4)`.
+
+
Returns:
+
tuple: `(matches, unmatched_detections, unmatched_tracks)`.
+
"""
+
return assign_tracks2detection_centroid_distances(
+
bbox_tracks, bbox_detections, distance_threshold=self.centroid_distance_threshold
+
)
+
+
+
[docs]
+
def update(self, bboxes, detection_scores, class_ids):
self.frame_count += 1
bbox_detections = np.array(bboxes, dtype='int')
@@ -293,9 +231,7 @@
Source code for motrackers.centroid_kf_tracker
if self.tracks[track_id].lost > self.max_lost:
self._remove_track(track_id)
else:
- matches, unmatched_detections, unmatched_tracks = assign_tracks2detection_centroid_distances(
- bbox_tracks, bbox_detections, distance_threshold=self.centroid_distance_threshold
- )
+ matches, unmatched_detections, unmatched_tracks = self._assign(bbox_tracks, bbox_detections)
for i in range(matches.shape[0]):
t, d = matches[i, :]
@@ -322,50 +258,36 @@
Source code for motrackers.centroid_kf_tracker
self._remove_track(track_id)
outputs = self._get_tracks(self.tracks)
- return outputs
+
return outputs
+
+
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/docs/_modules/motrackers/detectors/caffe.html b/docs/_modules/motrackers/detectors/caffe.html
index dd8d43c..f1561d7 100644
--- a/docs/_modules/motrackers/detectors/caffe.html
+++ b/docs/_modules/motrackers/detectors/caffe.html
@@ -1,88 +1,44 @@
-
+
-
-
-
motrackers.detectors.caffe — Multi-object trackers in Python 1.0.0 documentation
-
-
-
-
-
+
motrackers.detectors.caffe — Multi-object trackers in Python 0.1.1 documentation
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
-
-
-
-
-