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

Function embedding_distance

yolox/tracker/matching.py:113–129  ·  view source on GitHub ↗

:param tracks: list[STrack] :param detections: list[BaseTrack] :param metric: :return: cost_matrix np.ndarray

(tracks, detections, metric='cosine')

Source from the content-addressed store, hash-verified

111 return cost_matrix
112
113def embedding_distance(tracks, detections, metric='cosine'):
114 """
115 :param tracks: list[STrack]
116 :param detections: list[BaseTrack]
117 :param metric:
118 :return: cost_matrix np.ndarray
119 """
120
121 cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
122 if cost_matrix.size == 0:
123 return cost_matrix
124 det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
125 #for i, track in enumerate(tracks):
126 #cost_matrix[i, :] = np.maximum(0.0, cdist(track.smooth_feat.reshape(1,-1), det_features, metric))
127 track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
128 cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
129 return cost_matrix
130
131
132def gate_cost_matrix(kf, cost_matrix, tracks, detections, only_position=False):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected