vis4d.data.transforms.affine

Affine transformation.

Modified from mmdetection (https://github.com/open-mmlab/mmdetection).

Functions

get_rotation_matrix(rotate_degrees)

Generate rotation matrix.

get_scaling_matrix(scale_ratio)

Generate scaling matrix.

get_shear_matrix(x_shear_degrees, ...)

Generate shear matrix.

get_translation_matrix(x_trans, y_trans)

Generate translation matrix.

Classes

AffineBoxes2D(*[, in_keys, out_keys, ...])

Apply Affine to a list of 2D bounding boxes.

AffineImages(*[, in_keys, out_keys, ...])

Affine Images.

AffineParam

Parameters for Affine.

GenAffineParameters(*[, in_keys, out_keys, ...])

Random affine transform data augmentation.

class AffineBoxes2D(*, in_keys=['boxes2d', 'boxes2d_classes', 'boxes2d_track_ids', 'transforms.affine.warp_matrix', 'transforms.affine.height', 'transforms.affine.width'], out_keys=['boxes2d', 'boxes2d_classes', 'boxes2d_track_ids'], sensors=None, same_on_batch=True, **kwargs)[source]

Apply Affine to a list of 2D bounding boxes.

__call__(boxes, classes, track_ids, warp_matrix_list, height_list, width_list)[source]

Apply Affine to 2D bounding boxes.

Return type:

tuple[list[ndarray[Any, dtype[float32]]], list[ndarray[Any, dtype[int64]]], list[ndarray[Any, dtype[int64]]] | None]

class AffineImages(*, in_keys=['images', 'transforms.affine.warp_matrix', 'transforms.affine.height', 'transforms.affine.width'], out_keys=['images', 'input_hw'], sensors=None, same_on_batch=True, **kwargs)[source]

Affine Images.

__call__(images, warp_matrix_list, height_list, width_list)[source]

Affine a list of image of dimensions [N, H, W, C].

Return type:

tuple[list[ndarray[Any, dtype[float32]]], list[tuple[int, int]]]

class AffineParam[source]

Parameters for Affine.

class GenAffineParameters(*, in_keys=['input_hw'], out_keys=['transforms.affine'], sensors=None, same_on_batch=True, **kwargs)[source]

Random affine transform data augmentation.

This operation randomly generates affine transform matrix which including rotation, translation, shear, and scaling transforms.

__call__(input_hw)[source]

Compute the parameters and put them in the data dict.

Return type:

list[AffineParam]

get_rotation_matrix(rotate_degrees)[source]

Generate rotation matrix.

Parameters:

rotate_degrees (float) – Rotation degrees.

Return type:

ndarray[Any, dtype[float32]]

get_scaling_matrix(scale_ratio)[source]

Generate scaling matrix.

Parameters:

scale_ratio (float) – Scale ratio.

Return type:

ndarray[Any, dtype[float32]]

get_shear_matrix(x_shear_degrees, y_shear_degrees)[source]

Generate shear matrix.

Parameters:
  • x_shear_degrees (float) – X shear degrees.

  • y_shear_degrees (float) – Y shear degrees.

Return type:

ndarray[Any, dtype[float32]]

get_translation_matrix(x_trans, y_trans)[source]

Generate translation matrix.

Parameters:
  • x_trans (float) – X translation.

  • y_trans (float) – Y translation.

Return type:

ndarray[Any, dtype[float32]]