(boxes1, boxes2, add1=False)
return intersect_heights * intersect_widths
Compute pairwise intersection areas between boxes.

    Args:
        boxes1: a numpy array with shape [N, 4] holding N boxes
        boxes2: a numpy array with shape [M, 4] holding M boxes

    Returns:
        a numpy array with shape [N*M] representing pairwise intersection area
Compute pairwise intersection areas between boxes.
Compute pairwise intersection areas between boxes .
def intersection(boxes1, boxes2, add1=False):
    """Compute pairwise intersection areas between boxes.

    Args:
        boxes1: a numpy array with shape [N, 4] holding N boxes
        boxes2: a numpy array with shape [M, 4] holding M boxes

    Returns:
        a numpy array with shape [N*M] representing pairwise intersection area
    """
    [y_min1, x_min1, y_max1, x_max1] = np.split(boxes1, 4, axis=1)
    [y_min2, x_min2, y_max2, x_max2] = np.split(boxes2, 4, axis=1)

    all_pairs_min_ymax = np.minimum(y_max1, np.transpose(y_max2))
    all_pairs_max_ymin = np.maximum(y_min1, np.transpose(y_min2))
    if add1:
        all_pairs_min_ymax += 1.0
    intersect_heights = np.maximum(
        np.zeros(all_pairs_max_ymin.shape),
        all_pairs_min_ymax - all_pairs_max_ymin)

    all_pairs_min_xmax = np.minimum(x_max1, np.transpose(x_max2))
    all_pairs_max_xmin = np.maximum(x_min1, np.transpose(x_min2))
    if add1:
        all_pairs_min_xmax += 1.0
    intersect_widths = np.maximum(
        np.zeros(all_pairs_max_xmin.shape),
        all_pairs_min_xmax - all_pairs_max_xmin)
    return intersect_heights * intersect_widths
def intersection ( boxes1 , boxes2 , add1 = False ) : [ y_min1 , x_min1 , y_max1 , x_max1 ] = np . split ( boxes1 , 4 , axis = 1 ) [ y_min2 , x_min2 , y_max2 , x_max2 ] = np . split ( boxes2 , 4 , axis = 1 ) all_pairs_min_ymax = np . minimum ( y_max1 , np . transpose ( y_max2 ) ) all_pairs_max_ymin = np . maximum ( y_min1 , np . transpose ( y_min2 ) ) if add1 : all_pairs_min_ymax += 1.0 intersect_heights = np . maximum ( np . zeros ( all_pairs_max_ymin . shape ) , all_pairs_min_ymax - all_pairs_max_ymin ) all_pairs_min_xmax = np . minimum ( x_max1 , np . transpose ( x_max2 ) ) all_pairs_max_xmin = np . maximum ( x_min1 , np . transpose ( x_min2 ) ) if add1 : all_pairs_min_xmax += 1.0 intersect_widths = np . maximum ( np . zeros ( all_pairs_max_xmin . shape ) , all_pairs_min_xmax - all_pairs_max_xmin ) return intersect_heights * intersect_widths