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

Function embedding_distance2

tutorials/qdtrack/mot_online/matching.py:122–144  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected