def random_short_side_scale_jitter_list()

in lib/datasets/image_processor.py [0:0]


def random_short_side_scale_jitter_list(images, min_size,
                                        max_size, boxes=None):

    size = int(round(1.0 / np.random.uniform(1.0 / max_size, 1.0 / min_size)))

    height = images[0].shape[0]
    width = images[0].shape[1]
    if ((width <= height and width == size)
            or (height <= width and height == size)):
        return images, boxes
    new_width = size
    new_height = size
    if width < height:
        new_height = int(math.floor((float(height) / width) * size))
        if boxes is not None:
            boxes = boxes * float(new_height) / height
    else:
        new_width = int(math.floor((float(width) / height) * size))
        if boxes is not None:
            boxes = boxes * float(new_width) / width
    return [cv2.resize(image, (new_width, new_height),
                       interpolation=getattr(cv2, cfg.INTERPOLATION)
                       ).astype(np.float32)
            for image in images], boxes