CropResize

Function Usage

Cropping and 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 Cropping and Resizing.

Only Atlas inference product support this API.

Prototype

1
APP_ERROR CropResize(const Tensor &inputTensor, const std::vector<Rect> &cropRectVec, const std::vector<Size> &sizeVec, std::vector<Tensor> &outputTensorVec, const Interpolation interpolation = Interpolation::BILINEAR_SIMILAR_OPENCV, bool keepMargin = false, AscendStream& stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

inputTensor

Input

Tensor of type UINT8. The value cannot be empty. Memory needs to be allocated on the device or DVPP side.

The input tensor width range is [10, 4096], and the height range is [6, 4096]. If the format YUV400 is contained, the width range is [18, 4096].

cropRectVec

Input

List of cropping parameters (Rect class). The number must be the same as that of elements in the output tensor list.

sizeVec

Input

List of resizing parameters (Size class). The number must be the same as that of elements in the output tensor list.

outputTensorVec

Output

List of tensor classes after cropping and resizing.

interpolation

Input

Resizing mode of an input tensor:

1
2
3
HUAWEI_HIGH_ORDER_FILTER = 0
BILINEAR_SIMILAR_OPENCV = 1
NEAREST_NEIGHBOR_OPENCV = 2
The Atlas inference product support the following algorithms (defaulted to 1):
  • 0 and 1: conventional bilinear algorithm, whose compute process is similar to that of OpenCV. When the input and output images are both in RGB format and the resizing range is [1/32, 512], the maximum value difference of a single pixel from OpenCV is ±1.
  • 2: conventional nearest neighbor algorithm, whose compute process is close to that of OpenCV.

keepMargin

Input

Specifies whether to retain the invalid boundary in the tensor in the outputTensor.

The default value is false, indicating that the invalid boundary in the tensor is not reserved. The width and height of the output tensor are the same as those of the resizing width and height.

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.