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

Function iou_batch

yolox/sort_tracker/sort.py:36–52  ·  view source on GitHub ↗

From SORT: Computes IOU between two bboxes in the form [x1,y1,x2,y2]

(bb_test, bb_gt)

Source from the content-addressed store, hash-verified

34
35
36def iou_batch(bb_test, bb_gt):
37 """
38 From SORT: Computes IOU between two bboxes in the form [x1,y1,x2,y2]
39 """
40 bb_gt = np.expand_dims(bb_gt, 0)
41 bb_test = np.expand_dims(bb_test, 1)
42
43 xx1 = np.maximum(bb_test[..., 0], bb_gt[..., 0])
44 yy1 = np.maximum(bb_test[..., 1], bb_gt[..., 1])
45 xx2 = np.minimum(bb_test[..., 2], bb_gt[..., 2])
46 yy2 = np.minimum(bb_test[..., 3], bb_gt[..., 3])
47 w = np.maximum(0., xx2 - xx1)
48 h = np.maximum(0., yy2 - yy1)
49 wh = w * h
50 o = wh / ((bb_test[..., 2] - bb_test[..., 0]) * (bb_test[..., 3] - bb_test[..., 1])
51 + (bb_gt[..., 2] - bb_gt[..., 0]) * (bb_gt[..., 3] - bb_gt[..., 1]) - wh)
52 return(o)
53
54
55def convert_bbox_to_z(bbox):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected