CenterCrop
- class cocohelper.transforms.crop.CenterCrop[source]
Bases:
Transform
Perform a crop around the center of the image.
- Parameters:
w – The width of the area to crop.
h – The height of the area to crop.
mode – How to handle bbox values, pixels or percentages.
Method List
apply
(img, anns)Apply the transformation to the image array and its annotations.
compute_bbox_area
(bbox)Compute area from a bounding box.
transform_dataset
(coco, out_dir)Apply an abstract transformation on the whole dataset.
Attributes List
Methods Details
- apply(img, anns)[source]
Apply the transformation to the image array and its annotations.
- Parameters:
img (ndarray) – image array.
anns (List[dict]) – annotations for this image.
- Returns:
Transformed image array and annotations.
- Return type:
Tuple[ndarray, List[dict]]
- static compute_bbox_area(bbox)
Compute area from a bounding box.
- Parameters:
bbox (List[int]) – bounding box.
- Returns:
The area inside the given bounding box.
- Return type:
int
- transform_dataset(coco, out_dir)
Apply an abstract transformation on the whole dataset.
- TODO: should we apply on the whole dataset eagerly or use a lazy execution when the data is obtained?
In the first case, apply takes a COCODataset and returns a new modified COCODataset.
In the second case probably COCODataset should have a reference to a Transform and apply just-in-time when an element is retrieved.
- Parameters:
coco (COCOHelper) –
out_dir (Union[str, Path]) –
- Return type:
Attribute Details
- _abc_impl = <_abc._abc_data object>