(bbox, scale)
return expanded_bbox
Expand an array of boxes by a given scale.
Expand an array of boxes by a given scale.
Expand an array of boxes by a given scale .
def _expand_bbox(bbox, scale):
    """Expand an array of boxes by a given scale."""
    xp = chainer.backends.cuda.get_array_module(bbox)

    h_half = (bbox[:, 2] - bbox[:, 0]) * .5
    w_half = (bbox[:, 3] - bbox[:, 1]) * .5
    y_c = (bbox[:, 2] + bbox[:, 0]) * .5
    x_c = (bbox[:, 3] + bbox[:, 1]) * .5

    h_half *= scale
    w_half *= scale

    expanded_bbox = xp.zeros(bbox.shape)
    expanded_bbox[:, 0] = y_c - h_half
    expanded_bbox[:, 1] = x_c - w_half
    expanded_bbox[:, 2] = y_c + h_half
    expanded_bbox[:, 3] = x_c + w_half

    return expanded_bbox
def _expand_bbox ( bbox , scale ) : xp = chainer . backends . cuda . get_array_module ( bbox ) h_half = ( bbox [ : , 2 ] - bbox [ : , 0 ] ) * .5 w_half = ( bbox [ : , 3 ] - bbox [ : , 1 ] ) * .5 y_c = ( bbox [ : , 2 ] + bbox [ : , 0 ] ) * .5 x_c = ( bbox [ : , 3 ] + bbox [ : , 1 ] ) * .5 h_half *= scale w_half *= scale expanded_bbox = xp . zeros ( bbox . shape ) expanded_bbox [ : , 0 ] = y_c - h_half expanded_bbox [ : , 1 ] = x_c - w_half expanded_bbox [ : , 2 ] = y_c + h_half expanded_bbox [ : , 3 ] = x_c + w_half return expanded_bbox