matching

Utility functions for matching tracks to detections.

source

box_iou_batch

 box_iou_batch (boxes_true:numpy.ndarray, boxes_detection:numpy.ndarray)

Compute the Intersection over Union (IoU) between two sets of bounding boxes.

Type Details
boxes_true ndarray Ground truth bounding boxes, shape (N, 4) format (x_min, y_min, x_max, y_max).
boxes_detection ndarray Detected bounding boxes, shape (M, 4), format (x_min, y_min, x_max, y_max).
Returns ndarray IoU matrix of shape (N, M) where each element (i, j) represents the IoU between boxes_true[i] and boxes_detection[j].

source

indices_to_matches

 indices_to_matches (cost_matrix:numpy.ndarray, indices:tuple,
                     thresh:float)

Extract matched and unmatched indices based on a threshold.

Type Details
cost_matrix ndarray The matrix of costs.
indices tuple Indices of potential matches.
thresh float Threshold for valid matches.
Returns tuple Contains three elements: Matched indices., Unmatched indices from the first set. Unmatched indices from the second set.

source

linear_assignment

 linear_assignment (cost_matrix:numpy.ndarray, thresh:float)

Perform linear assignment to minimize the total cost.

Type Details
cost_matrix ndarray The matrix of costs.
thresh float Threshold for valid matches.
Returns tuple Contains three elements: Matched indices, Unmatched indices from the first set., Unmatched indices from the second set.

source

ious

 ious (atlbrs, btlbrs)

Compute the IoU between two sets of bounding boxes.

Type Details
atlbrs List of bounding boxes from the first set.
btlbrs List of bounding boxes from the second set.
Returns ndarray IoU matrix.

source

iou_distance

 iou_distance (atracks:list, btracks:list)

Compute the cost matrix based on IoU for two sets of tracks.

Type Details
atracks list List of tracks from the first set. Each track can be an ndarray or an object with a ‘tlbr’ attribute.
btracks list List of tracks from the second set. Each track can be an ndarray or an object with a ‘tlbr’ attribute.
Returns ndarray Cost matrix where each element (i, j) represents the cost of associating atracks[i] with btracks[j].

source

match_detections_with_tracks

 match_detections_with_tracks (tlbr_boxes:numpy.ndarray,
                               track_ids:numpy.ndarray,
                               tracks:List[cjm_byte_track.strack.STrack])

Match detected bounding boxes with existing tracks using Intersection Over Union (IOU).

Note: - If a detected bounding box does not match any existing track (i.e., IOU is zero), its corresponding track ID remains unchanged.

Type Details
tlbr_boxes ndarray An array of detected bounding boxes, represented as [top, left, bottom, right].
track_ids ndarray An array of track IDs corresponding to the input bounding boxes.
tracks typing.List[cjm_byte_track.strack.STrack] A list of track objects representing the current tracked objects.
Returns ndarray An array of updated track IDs where the detections are matched with the existing tracks.