ResizePaste

Function Usage

Resizing and pasting API of the Image class. It supports asynchronous execution. The tensor memory allocated by calling this API does not need to be managed by the users. It is released by the internal management module. Implicit memory allocation is supported. If the sizes of the pre-pasted images are different, resize the images first.

Only Atlas inference product support this API.

  • Supported input/output image formats of the tensor class:
  • Supported only by Atlas inference product. The image format must be YUV_400 or RGB_888. The input resolution cannot exceed 4096 x 4096.
  • background: The actual resolution range is [16 x 6, 4096 x 4096].
  • PasteRects: Its maximum resolution is 4096 x 4096, and the minimum resolution is 10 x 6.
  • If keepMargin is set to true in dst, the output width is automatically aligned to a multiple of 16. If the dst width is a multiple of 16 and the memory is on the DVPP side, the input background memory is reused.
  • The width and height of the resized image is a multiple of [1/32, 16] of the actual width and height range.
  • The value of inputPics must match the value of PasteRects, with the maximum value of 256.
  • The width of the inputPics region in the result image is a multiple of 16.
  • keepMargin determines whether the output result dst retains the invalid boundary in the tensor. If the dst reuses the memory of the background, the background determines whether to retain the invalid boundary based on the value of keepMargin. The value is defaulted to false.
  • If the input image is in YUV_400 format, the minimum resolution is 18 x 6.

Prototype

1
APP_ERROR ResizePaste(const MxBase::Tensor &background, std::vector<MxBase::Tensor> &inputPics, std::vector<MxBase::Rect> &pasteRects, MxBase::Tensor &dst, bool keepMargin = false, MxBase::AscendStream &stream = MxBase::AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

background

Input

Input tensor, target tensor to be pasted. The uint8 data type is supported. The tensor dimension can be HW (2-dimensional) or HWC (3-dimensional). The tensor width range is [16, 4096], the height range is [6, 4096], and the grayscale range is [18, 4096]. The data memory must be on the device side or DVPP side.

inputPics

Input

std::vector<Tensor> class, input tensor. Tensor group pasted to the target tensor. The uint8 input type is supported. The tensor dimension can be HW (2-dimensional) or HWC (3-dimensional). The tensor width range is [10, 4096], the height range is [6, 4096], and the grayscale range is [18, 4096]. The data memory must be on the device side or DVPP side.

PasteRects

Input

std::vector<Rect> class. Pasted image rectangle. The rectangle width is aligned upwards to a multiple of 16. After alignment, the width and height of the rectangle cannot exceed the background image range.

dst

Output

Tensor class, output tensor, pasting result. When keepMargin is set to true, the result is automatically aligned to a multiple of 16. The uint8 input type is supported. The tensor dimension can be HW (2-dimensional) or HWC (3-dimensional). The tensor width range is [10, 4096], the height range is [6, 4096], and the grayscale range is [18, 4096]. The data memory must be on the device side or DVPP side. If the dst width is a multiple of 16 and the memory is on the DVPP side, the input background memory is reused.

keepMargin

Input

Boolean type. It specifies whether to retain the invalid boundary in the output dst.

stream

Input

AscendStream type. The default value is AscendStream::DefaultStream(). When the parameter value is the default value, the API calling is a synchronous operation. In other cases, the API calling is an asynchronous operation.

Response Parameters

Data Structure

Description

APP_ERROR

For details about the returned error codes, see APP_ERROR Description.