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

Function IoB

flow-python/examples/application/utils.py:111–123  ·  view source on GitHub ↗
(rect1, rect2, iob_threshold)

Source from the content-addressed store, hash-verified

109
110
111def IoB(rect1, rect2, iob_threshold):
112 b = (rect2[:, 2] - rect2[:, 0] + 1) * (rect2[:, 3] - rect2[:, 1] + 1)
113 # from IPython import embed; embed() $TODO
114 xx1 = np.maximum(rect1[:, 0], rect2[:, 0])
115 yy1 = np.maximum(rect1[:, 1], rect2[:, 1])
116 xx2 = np.minimum(rect1[:, 2], rect2[:, 2])
117 yy2 = np.minimum(rect1[:, 3], rect2[:, 3])
118 dx = np.maximum(0, xx2 - xx1 + 1)
119 dy = np.maximum(0, yy2 - yy1 + 1)
120 i = dx * dy
121 ov = i / b
122 ov[b < 0] = 0
123 return ov
124
125
126def IoU(rect1, rect2, iob_threshold):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected