(bboxes, width, height)
return return_list
Crop boxes that are too big and get coordinates
    with respect to cutouts.

    Arguments:
        bboxes: a float numpy array of shape [n, 5],
            where each row is (xmin, ymin, xmax, ymax, score).
        width: a float number.
        height: a float number.

    Returns:
        dy, dx, edy, edx: a int numpy arrays of shape [n],
            coordinates of the boxes with respect to the cutouts.
        y, x, ey, ex: a int numpy arrays of shape [n],
            corrected ymin, xmin, ymax, xmax.
        h, w: a int numpy arrays of shape [n],
            just heights and widths of boxes.

        in the following order:
            [dy, edy, dx, edx, y, ey, x, ex, w, h].
Crop boxes that are too big and get coordinates
    with respect to cutouts.
Crop boxes that are too big and get coordinates with respect to cutouts .
def correct_bboxes(bboxes, width, height):
    """Crop boxes that are too big and get coordinates
    with respect to cutouts.

    Arguments:
        bboxes: a float numpy array of shape [n, 5],
            where each row is (xmin, ymin, xmax, ymax, score).
        width: a float number.
        height: a float number.

    Returns:
        dy, dx, edy, edx: a int numpy arrays of shape [n],
            coordinates of the boxes with respect to the cutouts.
        y, x, ey, ex: a int numpy arrays of shape [n],
            corrected ymin, xmin, ymax, xmax.
        h, w: a int numpy arrays of shape [n],
            just heights and widths of boxes.

        in the following order:
            [dy, edy, dx, edx, y, ey, x, ex, w, h].
    """

    x1, y1, x2, y2 = [bboxes[:, i] for i in range(4)]
    w, h = x2 - x1 + 1.0,  y2 - y1 + 1.0
    num_boxes = bboxes.shape[0]

    # 'e' stands for end
    # (x, y) -> (ex, ey)
    x, y, ex, ey = x1, y1, x2, y2

    # we need to cut out a box from the image.
    # (x, y, ex, ey) are corrected coordinates of the box
    # in the image.
    # (dx, dy, edx, edy) are coordinates of the box in the cutout
    # from the image.
    dx, dy = np.zeros((num_boxes,)), np.zeros((num_boxes,))
    edx, edy = w.copy() - 1.0, h.copy() - 1.0

    # if box's bottom right corner is too far right
    ind = np.where(ex > width - 1.0)[0]
    edx[ind] = w[ind] + width - 2.0 - ex[ind]
    ex[ind] = width - 1.0

    # if box's bottom right corner is too low
    ind = np.where(ey > height - 1.0)[0]
    edy[ind] = h[ind] + height - 2.0 - ey[ind]
    ey[ind] = height - 1.0

    # if box's top left corner is too far left
    ind = np.where(x < 0.0)[0]
    dx[ind] = 0.0 - x[ind]
    x[ind] = 0.0

    # if box's top left corner is too high
    ind = np.where(y < 0.0)[0]
    dy[ind] = 0.0 - y[ind]
    y[ind] = 0.0

    return_list = [dy, edy, dx, edx, y, ey, x, ex, w, h]
    return_list = [i.astype('int32') for i in return_list]

    return return_list
def correct_bboxes ( bboxes , width , height ) : x1 , y1 , x2 , y2 = [ bboxes [ : , i ] for i in range ( 4 ) ] w , h = x2 - x1 + 1.0 , y2 - y1 + 1.0 num_boxes = bboxes . shape [ 0 ] # 'e' stands for end # (x, y) -> (ex, ey) x , y , ex , ey = x1 , y1 , x2 , y2 # we need to cut out a box from the image. # (x, y, ex, ey) are corrected coordinates of the box # in the image. # (dx, dy, edx, edy) are coordinates of the box in the cutout # from the image. dx , dy = np . zeros ( ( num_boxes , ) ) , np . zeros ( ( num_boxes , ) ) edx , edy = w . copy ( ) - 1.0 , h . copy ( ) - 1.0 # if box's bottom right corner is too far right ind = np . where ( ex > width - 1.0 ) [ 0 ] edx [ ind ] = w [ ind ] + width - 2.0 - ex [ ind ] ex [ ind ] = width - 1.0 # if box's bottom right corner is too low ind = np . where ( ey > height - 1.0 ) [ 0 ] edy [ ind ] = h [ ind ] + height - 2.0 - ey [ ind ] ey [ ind ] = height - 1.0 # if box's top left corner is too far left ind = np . where ( x < 0.0 ) [ 0 ] dx [ ind ] = 0.0 - x [ ind ] x [ ind ] = 0.0 # if box's top left corner is too high ind = np . where ( y < 0.0 ) [ 0 ] dy [ ind ] = 0.0 - y [ ind ] y [ ind ] = 0.0 return_list = [ dy , edy , dx , edx , y , ey , x , ex , w , h ] return_list = [ i . astype ( 'int32' ) for i in return_list ] return return_list