Code QuizIntermediate IoU of Two Boxes
Find why this Intersection-over-Union routine computes the overlap incorrectly.
Codepython
def iou(a, b):
# boxes in (x1, y1, x2, y2)
ix1 = min(a[0], b[0])
iy1 = min(a[1], b[1])
ix2 = max(a[2], b[2])
iy2 = max(a[3], b[3])
inter = max(0, ix2 - ix1) * max(0, iy2 - iy1)
area_a = (a[2]-a[0]) * (a[3]-a[1])
area_b = (b[2]-b[0]) * (b[3]-b[1])
return inter / (area_a + area_b - inter)
What is the bug in this IoU computation?