Skip to content

Instantly share code, notes, and snippets.

@JanSellner
JanSellner / iou.py
Last active June 24, 2020 16:00 — forked from meyerjo/iou.py
Python code to compute the intersection of two boundingboxes
from typing import Tuple
def intersection_over_union(boxA: Tuple[float, float, float, float], boxB: Tuple[float, float, float, float]) -> float:
"""Calculates the intersection of union between two rectangles/bounding boxes.
See https://www.pyimagesearch.com/2016/11/07/intersection-over-union-iou-for-object-detection/ for more information about IOU.
Args:
boxA: First bounding box with coordinates in the format [xmin, ymin, xmax, ymax].