This article fixed link: https://www.lao-wang.com/?p=114 reprint: Searky July 31, 2017 in Lao Wang's website published
Orthogonal ratio (INTERSECTION-OVER-UNION,IOU), a concept used in target detection, is the rate of overlap between the resulting candidate frame (candidate bound) and the original marker box (ground truth bound), i.e. the ratio of their intersection to the set. Ideally, the total overlap, which is the ratio of 1.
Calculation formula:
Python implementation code:
def Calculateiou (Candidatebound, Groundtruthbound):
cx1 = candidatebound[0]
cy1 = candidatebound[1]
cx2 = CANDIDATEBOUND[2]
cy2 = candidatebound[3]
gx1 = groundtruthbound[0]
gy1 = groundtruthbound[1]
gx2 = GROUNDTRUTHBOUND[2]
gy2 = groundtruthbound[3]
Carea = (cx2-cx1) * (cy2-cy1) #C的面积
Garea = (gx2-gx1) * (g Y2-GY1) #G的面积
x1 = max (cx1, gx1)
y1 = max (Cy1, gy1)
x2 = min (cx2, gx2)
y2 = min (cy2, gy2)
w = m Ax (0, x2-x1)
h = max (0, y2-y1)
area = w * H #C ∩g
IOU = areas/(Carea + garea-area) return
IOU
def Calculateiou (Candidatebound, groundtruthbound): cx1 = candidatebound[0] Cy1 = candidatebound[1] cx2 = candidatebound[ 2] cy2 = candidatebound[3] gx1 = groundtruthbound[0] gy1 = groundtruthbound[1] gx2 = groundtruthbound[2] Gy2 = Groundtruth BOUND[3] Carea = (cx2-cx1) * (cy2-cy1) #C的面积 Garea = (gx2-gx1) * (gy2-gy1) #G的面积 x1 = max (cx1, gx1) y1 = max (Cy1, gy1) x2 = min (cx2, gx2) y2 = min (cy2, gy2) w = max (0, x2-x1) H = max (0, y2-y1) area = w * H #C ∩g size IOU = areas/(Care A + Garea-area) return IOU