MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / iou

Function iou

flow-python/examples/application/utils.py:18–29  ·  view source on GitHub ↗
(r0: np.array, r1: np.array)

Source from the content-addressed store, hash-verified

16
17
18def iou(r0: np.array, r1: np.array) -> float:
19 xx1 = max(r0[1], r1[1])
20 yy1 = max(r0[2], r1[2])
21 xx2 = min(r0[3], r1[3])
22 yy2 = min(r0[4], r1[4])
23 dx = max(0., xx2 - xx1)
24 dy = max(0, yy2 - yy1)
25 i = dx * dy
26 u = (r0[3] - r0[1]) * (r0[4] - r0[2]) + (r1[3] - r1[1]) * (r1[4] -
27 r1[2]) - i
28 iou = i / u
29 return iou
30
31
32def is_overlap(rect1: np.array, rect2: np.array, iou_thr: float) -> bool:

Callers 1

is_overlapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected