MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / matching_cascade

Function matching_cascade

yolox/deepsort_tracker/linear_assignment.py:76–136  ·  view source on GitHub ↗

Run matching cascade. Parameters ---------- distance_metric : Callable[List[Track], List[Detection], List[int], List[int]) -> ndarray The distance metric is given a list of tracks and detections as well as a list of N track indices and M detection indices. The metric shou

(
        distance_metric, max_distance, cascade_depth, tracks, detections,
        track_indices=None, detection_indices=None)

Source from the content-addressed store, hash-verified

74
75
76def matching_cascade(
77 distance_metric, max_distance, cascade_depth, tracks, detections,
78 track_indices=None, detection_indices=None):
79 """Run matching cascade.
80 Parameters
81 ----------
82 distance_metric : Callable[List[Track], List[Detection], List[int], List[int]) -> ndarray
83 The distance metric is given a list of tracks and detections as well as
84 a list of N track indices and M detection indices. The metric should
85 return the NxM dimensional cost matrix, where element (i, j) is the
86 association cost between the i-th track in the given track indices and
87 the j-th detection in the given detection indices.
88 max_distance : float
89 Gating threshold. Associations with cost larger than this value are
90 disregarded.
91 cascade_depth: int
92 The cascade depth, should be se to the maximum track age.
93 tracks : List[track.Track]
94 A list of predicted tracks at the current time step.
95 detections : List[detection.Detection]
96 A list of detections at the current time step.
97 track_indices : Optional[List[int]]
98 List of track indices that maps rows in `cost_matrix` to tracks in
99 `tracks` (see description above). Defaults to all tracks.
100 detection_indices : Optional[List[int]]
101 List of detection indices that maps columns in `cost_matrix` to
102 detections in `detections` (see description above). Defaults to all
103 detections.
104 Returns
105 -------
106 (List[(int, int)], List[int], List[int])
107 Returns a tuple with the following three entries:
108 * A list of matched track and detection indices.
109 * A list of unmatched track indices.
110 * A list of unmatched detection indices.
111 """
112 if track_indices is None:
113 track_indices = list(range(len(tracks)))
114 if detection_indices is None:
115 detection_indices = list(range(len(detections)))
116
117 unmatched_detections = detection_indices
118 matches = []
119 for level in range(cascade_depth):
120 if len(unmatched_detections) == 0: # No detections left
121 break
122
123 track_indices_l = [
124 k for k in track_indices
125 if tracks[k].time_since_update == 1 + level
126 ]
127 if len(track_indices_l) == 0: # Nothing to match at this level
128 continue
129
130 matches_l, _, unmatched_detections = \
131 min_cost_matching(
132 distance_metric, max_distance, tracks, detections,
133 track_indices_l, unmatched_detections)

Callers

nothing calls this directly

Calls 1

min_cost_matchingFunction · 0.85

Tested by

no test coverage detected