Example #1
0
    def apply_to_bbox(self, bbox, angle=0, **params):
        height = params["rows"]
        width = params["cols"]

        new_height, new_width = get_rotated_size(height, width, angle)
        bbox = F.bbox_rotate(bbox, angle, new_height, new_width, 0)

        crop_height, crop_width = rotatedRectWithMaxArea(height, width, angle)

        bbox = F.bbox_center_crop(bbox, crop_height, crop_width, new_height,
                                  new_width)

        resized_height, resized_width = get_resized_max_ratio(
            height, width, crop_height, crop_width)

        return F.bbox_center_crop(bbox, height, width, resized_height,
                                  resized_width)
Example #2
0
def test_bbox_center_crop():
    cropped_bbox = F.bbox_center_crop([0.5, 0.2, 0.9, 0.7], 64, 64, 100, 100)
    assert cropped_bbox == [0.5, 0.03125, 1.125, 0.8125]