:param tracks: list[STrack] :param detections: list[BaseTrack] :param metric: :return: cost_matrix np.ndarray
(tracks, detections, metric='cosine')
| 111 | return cost_matrix |
| 112 | |
| 113 | def 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 | |
| 132 | def gate_cost_matrix(kf, cost_matrix, tracks, detections, only_position=False): |
nothing calls this directly
no outgoing calls
no test coverage detected