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

Function embedding_distance2

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

118 return cost_matrix
119
120def embedding_distance2(tracks, detections, metric='cosine'):
121 """
122 :param tracks: list[STrack]
123 :param detections: list[BaseTrack]
124 :param metric:
125 :return: cost_matrix np.ndarray
126 """
127
128 cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
129 if cost_matrix.size == 0:
130 return cost_matrix
131 det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
132 #for i, track in enumerate(tracks):
133 #cost_matrix[i, :] = np.maximum(0.0, cdist(track.smooth_feat.reshape(1,-1), det_features, metric))
134 track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
135 cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
136 track_features = np.asarray([track.features[0] for track in tracks], dtype=np.float)
137 cost_matrix2 = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
138 track_features = np.asarray([track.features[len(track.features)-1] for track in tracks], dtype=np.float)
139 cost_matrix3 = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
140 for row in range(len(cost_matrix)):
141 cost_matrix[row] = (cost_matrix[row]+cost_matrix2[row]+cost_matrix3[row])/3
142 return cost_matrix
143
144
145def vis_id_feature_A_distance(tracks, detections, metric='cosine'):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected