vis4d.data.transforms.crop

Crop transformation.

Functions

absolute_crop(im_h, im_w, shape)

Absolute crop.

absolute_range_crop(im_h, im_w, shape)

Absolute range crop.

relative_crop(im_h, im_w, shape)

Relative crop.

relative_range_crop(im_h, im_w, shape)

Relative range crop.

Classes

CropBoxes2D(*[, in_keys, out_keys, sensors, ...])

Crop 2D bounding boxes.

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

Crop depth maps.

CropImages(*[, in_keys, out_keys, sensors, ...])

Crop Images.

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

Crop instance segmentation masks.

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

Crop Intrinsics.

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

Crop optical flows.

CropParam

Parameters for Crop.

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

Crop segmentation masks.

GenCentralCropParameters(*[, in_keys, ...])

Generate the parameters for a central crop operation.

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

Generate the parameters for a crop operation.

GenRandomSizeCropParameters(*[, in_keys, ...])

Generate the parameters for a random size crop operation.

class CropBoxes2D(*, in_keys=['boxes2d', 'boxes2d_classes', 'boxes2d_track_ids', 'transforms.crop.crop_box', 'transforms.crop.keep_mask'], out_keys=['boxes2d', 'boxes2d_classes', 'boxes2d_track_ids'], sensors=None, same_on_batch=True, **kwargs)[source]

Crop 2D bounding boxes.

__call__(boxes_list, classes_list, track_ids_list, crop_box_list, keep_mask_list)[source]

Crop 2D bounding boxes.

Parameters:
  • boxes_list (list[NDArrayF32]) – The list of bounding boxes to be cropped.

  • classes_list (list[NDArrayI64]) – The list of the corresponding classes.

  • track_ids_list (list[NDArrayI64] | None, optional) – The list of corresponding tracking IDs. Defaults to None.

  • crop_box_list (list[NDArrayI32]) – The list of box to crop.

  • keep_mask_list (list[NDArrayBool]) – Which boxes to keep.

Returns:

List of cropped bounding boxes according to parameters.

Return type:

tuple[list[NDArrayF32], list[NDArrayI64], list[NDArrayI64]] | None

class CropDepthMaps(*, in_keys=['depth_maps', 'transforms.crop.crop_box'], out_keys=['depth_maps'], sensors=None, same_on_batch=True, **kwargs)[source]

Crop depth maps.

__call__(depth_maps, crop_box_list)[source]

Crop depth maps.

Return type:

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

class CropImages(*, in_keys=['images', 'transforms.crop.crop_box'], out_keys=['images', 'input_hw'], sensors=None, same_on_batch=True, **kwargs)[source]

Crop Images.

__call__(images, crop_box_list)[source]

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

Parameters:
  • images (list[NDArrayF32]) – The list of image.

  • crop_box (list[NDArrayI32]) – The list of box to crop.

Returns:

List of cropped image according to parameters.

Return type:

list[NDArrayF32]

class CropInstanceMasks(*, in_keys=['instance_masks', 'transforms.crop.crop_box', 'transforms.crop.keep_mask'], out_keys=['instance_masks'], sensors=None, same_on_batch=True, **kwargs)[source]

Crop instance segmentation masks.

__call__(masks_list, crop_box_list, keep_mask_list)[source]

Crop masks.

Return type:

list[ndarray[Any, dtype[uint8]]]

class CropIntrinsics(*, in_keys=['intrinsics', 'transforms.crop.crop_box'], out_keys=['intrinsics'], sensors=None, same_on_batch=True, **kwargs)[source]

Crop Intrinsics.

__call__(intrinsics_list, crop_box_list)[source]

Crop camera intrinsics.

Return type:

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

class CropOpticalFlows(*, in_keys=['optical_flows', 'transforms.crop.crop_box'], out_keys=['optical_flows'], sensors=None, same_on_batch=True, **kwargs)[source]

Crop optical flows.

__call__(optical_flows, crop_box_list)[source]

Crop optical flows.

Return type:

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

class CropParam[source]

Parameters for Crop.

class CropSegMasks(*, in_keys=['seg_masks', 'transforms.crop.crop_box'], out_keys=['seg_masks'], sensors=None, same_on_batch=True, **kwargs)[source]

Crop segmentation masks.

__call__(masks_list, crop_box_list)[source]

Crop masks.

Return type:

list[ndarray[Any, dtype[uint8]]]

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

Generate the parameters for a central crop operation.

__call__(input_hw_list, boxes_list)[source]

Compute the parameters and put them in the data dict.

Return type:

list[CropParam]

class GenCropParameters(*, in_keys=['input_hw', 'boxes2d', 'seg_masks'], out_keys=['transforms.crop'], sensors=None, same_on_batch=True, **kwargs)[source]

Generate the parameters for a crop operation.

__call__(input_hw_list, boxes_list, masks_list)[source]

Compute the parameters and put them in the data dict.

Return type:

list[CropParam]

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

Generate the parameters for a random size crop operation.

A crop of the original image is made: the crop has a random area (H * W) and a random aspect ratio. Code adapted from torchvision.

__call__(input_hw_list, boxes_list)[source]

Compute the parameters and put them in the data dict.

Return type:

list[CropParam]

get_params(height, width)[source]

Get parameters for the random size crop.

Return type:

ndarray[Any, dtype[int32]]

absolute_crop(im_h, im_w, shape)[source]

Absolute crop.

Return type:

tuple[int, int]

absolute_range_crop(im_h, im_w, shape)[source]

Absolute range crop.

Return type:

tuple[int, int]

relative_crop(im_h, im_w, shape)[source]

Relative crop.

Return type:

tuple[int, int]

relative_range_crop(im_h, im_w, shape)[source]

Relative range crop.

Return type:

tuple[int, int]