def iou(bb, bbgt):
    """
    Single box IoU calculation function for ious

    Args:
        bb: bounding box 1
        bbgt: bounding box 2

    Returns:
        float: the IoU between the two boxes
    """
    ov = 0
    iw = min(bb[2], bbgt[2]) - max(bb[0], bbgt[0]) + 1
    ih = min(bb[3], bbgt[3]) - max(bb[1], bbgt[1]) + 1
    if iw > 0 and ih > 0:
        # compute overlap as area of intersection / area of union
        intersect = iw * ih
        ua = (bb[2] - bb[0] + 1.) * (bb[3] - bb[1] + 1.) + \
             (bbgt[2] - bbgt[0] + 1.) * \
             (bbgt[3] - bbgt[1] + 1.) - intersect
        ov = intersect / ua
    return ov