Resize

Function Usage

Image resizing API of the ImageProcessor class. Atlas inference product and Atlas 800I A2 inference product support asynchronous execution. The Image memory allocated using this API does not need to be managed by the user and is released internally. For details about the resizing effect, see Figure 1.

For details, see Resizing.

  • Supported input/output formats of the Image class:
    • Atlas 200/300/500 inference product supports YUV_SP_420 and YVU_SP_420 (nv12 and nv21).
    • Atlas 200I/500 A2 inference product supports YUV_SP_420 and YVU_SP_420 (nv12 and nv21).
    • Atlas inference product and Atlas 800I A2 inference product support YUV_SP_420, YVU_SP_420, RGB_888 and BGR_888 (nv12, nv21, rgb, and bgr). The resolution of the RGB (BGR) image format cannot exceed 4096 x 4096.
  • inputImage: The actual image resolution range is [18 × 6, 4096 × 4096]. The size of YUV_SP_420 or YVU_SP_420 image can reach 8192 x 8192.
  • resize: Its maximum resolution is 4096 x 4096, and the minimum resolution is 32 x 6.
  • outputImage: The width is automatically aligned by 16, and the height is automatically aligned by 2. So the size range is [32 x 6, 4096 x 4096].
  • The width and height of the resized image cannot exceed a multiple of [1/32, 16] of the actual width and height.
Figure 1 Resizing

Prototype

1
APP_ERROR ImageProcessor::Resize(const Image& inputImage, const Size& resize, Image& outputImage, const Interpolation interpolation, AscendStream& stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

inputImage

Input

Image class before resizing. The Image class obtained by the Decode API and other VPC APIs can be directly used as inputs. If the user-defined Image class is used, set the original and aligned image widths and heights.

resize

Input

Height and width for resizing

interpolation

Input

Resizing mode of an input image:

1
2
3
4
5
HUAWEI_HIGH_ORDER_FILTER = 0
BILINEAR_SIMILAR_OPENCV = 1
NEAREST_NEIGHBOR_OPENCV = 2
BILINEAR_SIMILAR_TENSORFLOW = 3
NEAREST_NEIGHBOR_TENSORFLOW = 4
The following algorithms are supported by the Atlas 200/300/500 inference product :
  • 0 (default): Huawei-developed high-order filtering algorithm.
  • 1: conventional bilinear algorithm, whose compute accuracy is close to that of OpenCV.
  • 2: conventional nearest neighbor algorithm, whose compute accuracy is close to that of OpenCV.
  • 3: conventional bilinear algorithm, whose compute accuracy is close to that of TensorFlow.
  • 4: conventional nearest neighbor algorithm, whose compute accuracy is close to that of TensorFlow.
The following algorithms are supported by the Atlas 200I/500 A2 inference product :
  • 0 (default): Huawei-developed high-order filtering algorithm.
  • 1: conventional bilinear algorithm, whose compute accuracy is close to that of OpenCV.
  • 2: conventional nearest neighbor algorithm, whose compute accuracy is close to that of OpenCV.
  • 3: conventional bilinear algorithm, whose compute accuracy is close to that of TensorFlow.
  • 4: conventional nearest neighbor algorithm, whose compute accuracy is close to that of TensorFlow.
Atlas inference product and Atlas 800I A2 inference product support the following algorithms (defaulted to 0 during synchronous execution):
  • 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.

outputImage

Output

Image class after resizing

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.