WarpAffineHiper

Function Usage

Affine transformation API. It is used to resize, translate, and rotate two-dimensional images. Asynchronous calling is supported.

Only Atlas inference product support this API.

The following conditions must be met:

  • The input and output tensors must be on the device or DVPP side, and the parameters (stream and data memory) must be on the same device.
  • For synchronization, the device where the data memory is located must be the same as the initialized device.
  • The output tensor can be an empty tensor. (When the tensor is an empty tensor, the output shape is the same as the shape of the input tensor.)
  • When the data type of the input tensor is Float32 or Uint8 and the recommended size is 480p (640 x 480), the compute performance is better than that of cv::warpAffine on the CPU.

Prototype

1
APP_ERROR WarpAffineHiper(const Tensor &src, Tensor &dst, const std::vector<std::vector<float>> transMatrix,const PaddingMode paddingMode, const float borderValue,const WarpAffineMode warpAffineMode, AscendStream& stream=AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

src

Input

Tensor class, input tensor that requires affine transformation. The uint8, float16, and float32 types are supported. The dimension must be NHWC (four-dimensional). The range of N (number of tensors) is [1, 16], and that of C (number of channels) is [1, 4]. The tensor width range is [32, 2160], the tensor height range is [32, 3840], and the data memory must be on the device or DVPP. Empty tensor cannot be passed.

dst

Output

Tensor class, output tensor. If the tensor is not empty, call Tensor.Malloc() to allocate memory in advance. The dimension must be NHWC (four-dimensional). The data type, chip ID, N (number of tensors), and C (number of channels) must be the same as those of the input tensor. The tensor width range is [32, 2160], and the tensor height range is [32, 3840]. The data memory must be on the device or DVPP. If a tensor is empty, its output shape is the same as the shape of the input tensor by default.

transMatrix

Input

Transformation matrix. The size must be in 2x3 format. (0,0,1) is added to the third row of the API to form a 3x3 matrix. The matrix determinant value cannot be 0.

paddingMode

Input

Enumeration class, corresponding to the padding mode. Only constant values (PADDING_CONST) are supported. For details, see PaddingMode.

borderValue

Input

Padding value, in the range of [0, 255].

WarpAffineMode

Input

Enumeration class, corresponding to the interpolation mode. Only bilinear interpolation (INTER_LINEAR) is supported. For details, see WarpAffineMode.

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.

If the "Synchronize stream execution failed" error occurs when the WarpAffineHiper API is executed, handle the issue by referring to Error "Synchronize stream execution failed" Occurs When WarpAffineHiper or WarpPerspective Is Running.