(rp, gt)
return overlaps
Returns a matrix of overlaps between every possible pair of the two provided
    bounding box lists.

    Arguments:
        rp (list): an array of region proposals, shape (R, 4)
        gt (list): an array of ground truth ROIs, shape (G, 4)

    Outputs:
        overlaps: a matrix of overlaps between 2 list, shape (R, G)
Returns a matrix of overlaps between every possible pair of the two provided
    bounding box lists.
Returns a matrix of overlaps between every possible pair of the two provided bounding box lists .
def calculate_bb_overlap(rp, gt):
    """
    Returns a matrix of overlaps between every possible pair of the two provided
    bounding box lists.

    Arguments:
        rp (list): an array of region proposals, shape (R, 4)
        gt (list): an array of ground truth ROIs, shape (G, 4)

    Outputs:
        overlaps: a matrix of overlaps between 2 list, shape (R, G)
    """
    R = rp.shape[0]
    G = gt.shape[0]
    overlaps = np.zeros((R, G), dtype=np.float32)

    for g in range(G):
        gt_box_area = float(
            (gt[g, 2] - gt[g, 0] + 1) *
            (gt[g, 3] - gt[g, 1] + 1)
        )
        for r in range(R):
            iw = float(
                min(rp[r, 2], gt[g, 2]) -
                max(rp[r, 0], gt[g, 0]) + 1
            )
            if iw > 0:
                ih = float(
                    min(rp[r, 3], gt[g, 3]) -
                    max(rp[r, 1], gt[g, 1]) + 1
                )
                if ih > 0:
                    ua = float(
                        (rp[r, 2] - rp[r, 0] + 1) *
                        (rp[r, 3] - rp[r, 1] + 1) +
                        gt_box_area - iw * ih
                    )
                    overlaps[r, g] = iw * ih / ua
    return overlaps
def calculate_bb_overlap ( rp , gt ) : R = rp . shape [ 0 ] G = gt . shape [ 0 ] overlaps = np . zeros ( ( R , G ) , dtype = np . float32 ) for g in range ( G ) : gt_box_area = float ( ( gt [ g , 2 ] - gt [ g , 0 ] + 1 ) * ( gt [ g , 3 ] - gt [ g , 1 ] + 1 ) ) for r in range ( R ) : iw = float ( min ( rp [ r , 2 ] , gt [ g , 2 ] ) - max ( rp [ r , 0 ] , gt [ g , 0 ] ) + 1 ) if iw > 0 : ih = float ( min ( rp [ r , 3 ] , gt [ g , 3 ] ) - max ( rp [ r , 1 ] , gt [ g , 1 ] ) + 1 ) if ih > 0 : ua = float ( ( rp [ r , 2 ] - rp [ r , 0 ] + 1 ) * ( rp [ r , 3 ] - rp [ r , 1 ] + 1 ) + gt_box_area - iw * ih ) overlaps [ r , g ] = iw * ih / ua return overlaps