Resize
Function Usage
Resizing API of the tensor 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.
For details, see Resizing.
Only Atlas inference product and Atlas 800I A2 inference server support this API.
- The input and output tensors support the YUV_400 and RGB_888 image formats, with input resolution of 4096 x 4096 or smaller.
- For the Atlas inference product, if the data type of the input tensor is uint8, RGBA images are supported.
- RGBA images are not supported by the Atlas 800I A2 inference server.
- If the input tensor dimension is HW or HWC (C =1 or 3), the valid region can be set. In this case, scaling is performed based on the valid region. For details about how to set the valid region, see Tensor. A valid region cannot be set for the output tensor.
Prototype
1 | APP_ERROR Resize(const Tensor &src, Tensor &dst, const Size &resize, const Interpolation interpolation = Interpolation::BILINEAR_SIMILAR_OPENCV, bool keepMargin = false, AscendStream& stream = AscendStream::DefaultStream()); |
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
src |
Input |
Tensor class, input tensor, which cannot be empty. Memory needs to be allocated on the device or DVPP. The dimension must be HW or HWC (C=1, 3, or 4).
|
||
dst |
Output |
Tensor class, output tensor. For the Atlas 800I A2 inference server, the data type is unit8. For the Atlas inference product, the data type is unit8 or float16. An empty tensor can be passed. If the value is not empty, the shape must be the same as that after the width and height are resized . Call Tensor.Malloc() to allocate memory in advance. The data memory must be on the device (the same device as that of src) or DVPP. |
||
resize |
Input |
Resizing width and height of the input tensor. For details, see Size. Maximum resolution: 4096 x 4096; minimum resolution: 10 x 6. When the input image format is YUV_400, the minimum resolution is 18 x 6. The width and height range of the resized image is a multiple of [1/32, 32] of the actual width and height range. If a valid region is set for the input tensor, the width and height of the resized image cannot exceed a multiple of [1/32, 32] of the valid region. |
||
interpolation |
Input |
Resizing mode of an input tensor:
The following algorithms (defaulted to 1) are supported:
|
||
keepMargin |
Input |
Specifies whether to retain the invalid boundary in the tensor in the dst. The default value is false, indicating that the invalid boundary in the tensor is not reserved. That is, the width and height of the output tensor are the same as those of the resizing parameter. If keepMargin is set to true, the output width is automatically 16-pixel aligned. (For non-RGBA images of the Atlas inference product, this parameter does not take effect.) |
||
stream |
Input |
Stream used for asynchronous execution. The default value is AscendStream::DefaultStream(), indicating that a default stream is created (for synchronous execution). |
Response Parameters
Data Structure |
Description |
|---|---|
APP_ERROR |
For details about the returned error codes, see APP_ERROR Description. |