Skip to content

Instantly share code, notes, and snippets.

View meyerjo's full-sized avatar

Johannes Meyer meyerjo

  • Freiburg im Breisgau, Germany
View GitHub Profile
@meyerjo
meyerjo / iou.py
Last active July 17, 2024 18:01
Python code to compute the intersection of two boundingboxes
def bb_intersection_over_union(boxA, boxB):
# determine the (x, y)-coordinates of the intersection rectangle
xA = max(boxA[0], boxB[0])
yA = max(boxA[1], boxB[1])
xB = min(boxA[2], boxB[2])
yB = min(boxA[3], boxB[3])
# compute the area of intersection rectangle
interArea = abs(max((xB - xA, 0)) * max((yB - yA), 0))
if interArea == 0: