Invalidate infeasible entries in cost matrix based on the state distributions obtained by Kalman filtering. Parameters ---------- kf : The Kalman filter. cost_matrix : ndarray The NxM dimensional cost matrix, where N is the number of track indices and M is the num
(
kf, cost_matrix, tracks, detections, track_indices, detection_indices,
gated_cost=INFTY_COST, only_position=False)
| 137 | |
| 138 | |
| 139 | def gate_cost_matrix( |
| 140 | kf, cost_matrix, tracks, detections, track_indices, detection_indices, |
| 141 | gated_cost=INFTY_COST, only_position=False): |
| 142 | """Invalidate infeasible entries in cost matrix based on the state |
| 143 | distributions obtained by Kalman filtering. |
| 144 | Parameters |
| 145 | ---------- |
| 146 | kf : The Kalman filter. |
| 147 | cost_matrix : ndarray |
| 148 | The NxM dimensional cost matrix, where N is the number of track indices |
| 149 | and M is the number of detection indices, such that entry (i, j) is the |
| 150 | association cost between `tracks[track_indices[i]]` and |
| 151 | `detections[detection_indices[j]]`. |
| 152 | tracks : List[track.Track] |
| 153 | A list of predicted tracks at the current time step. |
| 154 | detections : List[detection.Detection] |
| 155 | A list of detections at the current time step. |
| 156 | track_indices : List[int] |
| 157 | List of track indices that maps rows in `cost_matrix` to tracks in |
| 158 | `tracks` (see description above). |
| 159 | detection_indices : List[int] |
| 160 | List of detection indices that maps columns in `cost_matrix` to |
| 161 | detections in `detections` (see description above). |
| 162 | gated_cost : Optional[float] |
| 163 | Entries in the cost matrix corresponding to infeasible associations are |
| 164 | set this value. Defaults to a very large value. |
| 165 | only_position : Optional[bool] |
| 166 | If True, only the x, y position of the state distribution is considered |
| 167 | during gating. Defaults to False. |
| 168 | Returns |
| 169 | ------- |
| 170 | ndarray |
| 171 | Returns the modified cost matrix. |
| 172 | """ |
| 173 | gating_dim = 2 if only_position else 4 |
| 174 | gating_threshold = kalman_filter.chi2inv95[gating_dim] |
| 175 | measurements = np.asarray( |
| 176 | [detections[i].to_xyah() for i in detection_indices]) |
| 177 | for row, track_idx in enumerate(track_indices): |
| 178 | track = tracks[track_idx] |
| 179 | gating_distance = kf.gating_distance( |
| 180 | track.mean, track.covariance, measurements, only_position) |
| 181 | cost_matrix[row, gating_distance > gating_threshold] = gated_cost |
| 182 | return cost_matrix |
nothing calls this directly
no test coverage detected