def calculate_iou(bbox1, bbox2):
    """
    calculate iou
    args:
    - bbox1 [array]: 1x4 single bbox
    - bbox2 [array]: 1x4 single bbox
    returns:
    - iou [float]: iou between 2 bboxes
    """
    xmin = max(bbox1[0], bbox2[0]) # x_left
    ymin = max(bbox1[1], bbox2[1]) # y_top
    xmax = min(bbox1[2], bbox2[2]) # x_right
    ymax = min(bbox1[3], bbox2[3]) # y_bottom

    intersection = max(0, xmax - xmin + 1) * max(0, ymax - ymin + 1)
    bbox1_area = (bbox1[2] - bbox1[0]) * (bbox1[3] - bbox1[1])
    bbox2_area = (bbox2[2] - bbox2[0]) * (bbox2[3] - bbox2[1])

    union = bbox1_area + bbox2_area - intersection
    return intersection / union