nvidia.dali.fn.bbox_rotate#
- nvidia.dali.fn.bbox_rotate(__bboxes, __labels=None, /, *, angle, bbox_layout='xyXY', bbox_normalized=True, bytes_per_sample_hint=[0], input_shape, keep_size=False, mode='expand', preserve=False, remove_threshold=0.1, shape_layout='HW', size=[], device=None, name=None)#
Transforms bounding boxes so that the boxes remain in the same place in the image after the image is rotated. Boxes that land outside the image with
keep_size=True
will be removed from the output if the fraction of the remaining box after cropping is less thanremove_threshold
. Iflabels
are passed as a second argument, they will also be removed synchronously.By default, boxes are expanded when rotated to ensure the original box is fully enclosed. This can be controlled with
mode
which can either retain the original height and width withmode='fixed'
or between the full expansion and original shape withmode='halfway'
.Warning
Boxes should be rotated first before the image as this op requires the original image shape to calculate the rotated boxes.
Example usage is below:
boxes, labels = fn.bbox_rotate( boxes, labels, angle=angle, input_shape=image.shape(), keep_size=keep_size ) image = fn.rotate(image, angle=angle, keep_size=keep_size)
- Supported backends
‘cpu’
- Parameters:
__bboxes¶ (2D TensorList of float) – Coordinates of the bounding boxes that are represented as a [N,4] 2D tensor.
__labels¶ (1D or 2D TensorList of int, optional) – Class labels for the bounding boxes, [N] or [N,1]. These should be provided if
keep_size=True
as boxes may be truncated, this ensures the corresponding class labels are also removed.
- Keyword Arguments:
angle¶ (float or TensorList of float) – Rotation angle in degrees.
bbox_layout¶ (layout str, optional, default = ‘xyXY’) – Format of the bounding box input
xyWH
orxyXY
.bbox_normalized¶ (bool, optional, default = True) – Input bounding boxes are in normalized [0,1] format
bytes_per_sample_hint¶ (int or list of int, optional, default = [0]) –
Output size hint, in bytes per sample.
If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size.
input_shape¶ (int or list of int or TensorList of int) –
Specifies the shape of the original image the boxes belong to.
The order of dimensions is determined by the layout that is provided in
shape_layout
.keep_size¶ (bool, optional, default = False) – If true, the bounding box output coordinates will assume the image canvas size was also kept (see
nvidia.dali.fn.rotate
).mode¶ (str, optional, default = ‘expand’) –
Mode of the bounding box transformation. Possible values are:
expand
: expands the bounding box to definitely enclose the target, but may be larger than rotated target.fixed
: retains the original size of the bounding box, but may be smaller than the rotated target.halfway
: halfway between the expanded size and the original size.
Note
Modes other than
expand
are not recommended for datasets with high aspect ratio boxes and high rotation angles.preserve¶ (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used.
remove_threshold¶ (float, optional, default = 0.1) – Relative area remaining threshold for removing boxes that fall outside the image boundaries after rotation. Should be between [0-1] where 0 means no removal even if box lies outside, 1 means removal if any part of the box is outside.
shape_layout¶ (layout str, optional, default = ‘HW’) –
Determines the meaning of the dimensions provided in
input_shape
.Note
If unspecified,
"HW"
will be assumed, which is also compatible with"HWC"
since we select H and W internally (index 0, 1).size¶ (float or list of float or TensorList of float, optional, default = []) – The output canvas size optionally specified in the associated fn.rotate.