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

Function is_overlap_v2

flow-python/examples/application/utils.py:83–94  ·  view source on GitHub ↗
(rect1, rect2, iou_threshold)

Source from the content-addressed store, hash-verified

81
82
83def is_overlap_v2(rect1, rect2, iou_threshold):
84 xx1 = max(rect1[0], rect2[0])
85 yy1 = max(rect1[1], rect2[1])
86 xx2 = min(rect1[2], rect2[2])
87 yy2 = min(rect1[3], rect2[3])
88 dx = max(0, xx2 - xx1 + 1)
89 dy = max(0, yy2 - yy1 + 1)
90 i = dx * dy
91 u = (rect1[2] - rect1[0] + 1) * (rect1[3] - rect1[1] + 1) + (
92 rect2[2] - rect2[0] + 1) * (rect2[3] - rect2[1] + 1) - i
93 ov = i / u
94 return rect1[4] * rect2[4] < ov or ov >= iou_threshold
95
96
97def is_overlap_v1(rect1, rect2, iou_threshold):

Callers 1

nmsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected