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

Function embedding_distance

tutorials/ctracker/mot_online/matching.py:104–120  ·  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

102 return cost_matrix
103
104def embedding_distance(tracks, detections, metric='cosine'):
105 """
106 :param tracks: list[STrack]
107 :param detections: list[BaseTrack]
108 :param metric:
109 :return: cost_matrix np.ndarray
110 """
111
112 cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
113 if cost_matrix.size == 0:
114 return cost_matrix
115 det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
116 #for i, track in enumerate(tracks):
117 #cost_matrix[i, :] = np.maximum(0.0, cdist(track.smooth_feat.reshape(1,-1), det_features, metric))
118 track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
119 cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
120 return cost_matrix
121
122def embedding_distance2(tracks, detections, metric='cosine'):
123 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected