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

Function iou

yolox/deepsort_tracker/iou_matching.py:7–36  ·  view source on GitHub ↗

Computer intersection over union. Parameters ---------- bbox : ndarray A bounding box in format `(top left x, top left y, width, height)`. candidates : ndarray A matrix of candidate bounding boxes (one per row) in the same format as `bbox`. Returns ---

(bbox, candidates)

Source from the content-addressed store, hash-verified

5
6
7def iou(bbox, candidates):
8 """Computer intersection over union.
9 Parameters
10 ----------
11 bbox : ndarray
12 A bounding box in format `(top left x, top left y, width, height)`.
13 candidates : ndarray
14 A matrix of candidate bounding boxes (one per row) in the same format
15 as `bbox`.
16 Returns
17 -------
18 ndarray
19 The intersection over union in [0, 1] between the `bbox` and each
20 candidate. A higher score means a larger fraction of the `bbox` is
21 occluded by the candidate.
22 """
23 bbox_tl, bbox_br = bbox[:2], bbox[:2] + bbox[2:]
24 candidates_tl = candidates[:, :2]
25 candidates_br = candidates[:, :2] + candidates[:, 2:]
26
27 tl = np.c_[np.maximum(bbox_tl[0], candidates_tl[:, 0])[:, np.newaxis],
28 np.maximum(bbox_tl[1], candidates_tl[:, 1])[:, np.newaxis]]
29 br = np.c_[np.minimum(bbox_br[0], candidates_br[:, 0])[:, np.newaxis],
30 np.minimum(bbox_br[1], candidates_br[:, 1])[:, np.newaxis]]
31 wh = np.maximum(0., br - tl)
32
33 area_intersection = wh.prod(axis=1)
34 area_bbox = bbox[2:].prod()
35 area_candidates = candidates[:, 2:].prod(axis=1)
36 return area_intersection / (area_bbox + area_candidates - area_intersection)
37
38
39def iou_cost(tracks, detections, track_indices=None,

Callers 1

iou_costFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected