box_function
data.transform.box_function
NumpyBoxes
Bases: ndarray
rotate_polygons
rotate_polygons(polygons: PolygonType, angle: float, image_size: Tuple[int], target_size: Optional[Tuple[int]] = None) -> PolygonType
Source code in SaigeToolkit/data/transform/polygon_function.py
calculate_transform_matrix
calculate_transform_matrix(width: int, height: int, offset_top_left: OffsetType, offset_top_right: OffsetType, offset_bottom_right: OffsetType, offset_bottom_left: OffsetType) -> ndarray
Calculates the perspective transformation matrix using the given width, height, and corner points of a rectangle.
Parameters:
-
width(int) –Width of the original image.
-
height(int) –Height of the original image.
-
offset_top_left(OffsetType) – -
offset_bottom_right(OffsetType) – -
offset_top_right(OffsetType) –The offset ratio of the top-left corner point.
-
offset_bottom_left(OffsetType) –The offset ratio of the bottom-left corner point.
Returns:
-
ndarray–np.ndarray: The 4x3 perspective transform matrix.
Source code in SaigeToolkit/data/transform/augmentation/augment_function.py
check_value
Source code in SaigeToolkit/data/transform/function_util.py
preserve_coordinates
Box augmentation이 (left, top, right, bottom) coordinate system을 기반으로 구현 되어있기 때문에, input bboxes의 coordinate system을 확인하고 augmentation에 맞는 coordinate system으로 변환하고, augmentation이 끝나면 다시 기존 coordinate system으로 변경하여 출력합니다.
-
np.ndarray의 경우 coordinate system을 체크할 수 없기 때문에 (left, top, right, bottom) coordinate system이라고 가정합니다.
-
NumpyBBoxes의 경우 NumpyBBoxes 내부 변수 coordinate과 내부 함수 convert_coordinate를 활용하여 구현됩니다.
Source code in SaigeToolkit/data/transform/box_function.py
resize_box
resize_box(bboxes: BBoxesType, image_size: Tuple[int], tw: int, th: int) -> BBoxesType
bbox resize from (w, h) to (tw, th)
Source code in SaigeToolkit/data/transform/box_function.py
crop_box
crop_box(bboxes: BBoxesType, cropping_box: Union[ndarray, List[int]]) -> BBoxesType
bbox crop. An image is cropped at (new_left, new_top, new_right, new_bottom)
Source code in SaigeToolkit/data/transform/box_function.py
hflip_box
hflip_box(bboxes: BBoxesType, image_size: Tuple[int]) -> BBoxesType
vflip_box
vflip_box(bboxes: BBoxesType, image_size: Tuple[int]) -> BBoxesType
rotate
rotate(bboxes: BBoxesType, angle: Union[float, int], image_size: Tuple[int], target_size: Optional[Tuple[int]] = None, clipping: bool = True) -> BBoxesType
Source code in SaigeToolkit/data/transform/box_function.py
rotate90
rotate90(bboxes: BBoxesType, factor: int, image_size: Tuple[int], clipping: bool = True) -> BBoxesType
Source code in SaigeToolkit/data/transform/box_function.py
translate_box
translate_box(bboxes: BBoxesType, offset: Tuple[int], image_size: Tuple[int]) -> BBoxesType
Source code in SaigeToolkit/data/transform/box_function.py
ratio_jitter
ratio_jitter(bboxes: BBoxesType, image_size: Tuple[int], proportion_left: float = 0.0, proportion_right: float = 0.0, proportion_top: float = 0.0, proportion_bottom: float = 0.0) -> BBoxesType
Source code in SaigeToolkit/data/transform/box_function.py
zoom
zoom(bboxes: BBoxesType, image_size: Tuple[int], ratio: float = 1.0, h_start: float = 0.0, w_start: float = 0.0) -> BBoxesType
Source code in SaigeToolkit/data/transform/box_function.py
random_resized_crop_and_pad
random_resized_crop_and_pad(bboxes: BBoxesType, image_size: Tuple[int], scale: float = 1.0, aspect_ratio: float = 1.0, h_start: float = 0.0, w_start: float = 0.0, height: Optional[int] = None, width: Optional[int] = None) -> BBoxesType
Source code in SaigeToolkit/data/transform/box_function.py
perspective_transform
perspective_transform(bboxes: BBoxesType, image_size: Tuple[int], offset_top_left: OffsetType, offset_top_right: OffsetType, offset_bottom_right: OffsetType, offset_bottom_left: OffsetType) -> BBoxesType