def calculate_iou(p1, p2):
    a1 = p1.area
    a2 = p2.area
    intersection = p1.intersection(p2).area
    return (intersection / ((a1 + a2) - intersection))
def calculate_iou(p1, p2):
    a1 = p1.area
    a2 = p2.area
    intersection = p1.intersection(p2).area
    return (intersection / ((a1 + a2) - intersection))