mxpi_imageresize

Function

Resizes the decoded YUV and RGB images with the specified width and height. YUV_420 supports both 4 KB and 8 KB images. Other types of YUV images, such as YUV422 and YUV444, support only 4 KB images. The RGB format can be RGB888 or BGR888.

Synchronous/Asynchronous (Status)

Asynchronous

Constraints

  • Formats that support both 4K and 8K images:
    MXPI_PIXEL_FORMAT_YUV_SEMIPLANAR_420 = 1, // 1, YUV420SP NV12 8bit
    MXPI_PIXEL_FORMAT_YVU_SEMIPLANAR_420 = 2, // 2, YUV420SP NV21 8bit
  • Formats that support only 4K images:
    MXPI_PIXEL_FORMAT_YUV_400 = 0, // 0, YUV400 8bit
    MXPI_PIXEL_FORMAT_YUV_SEMIPLANAR_422 = 3, // 3, YUV422SP NV12 8bit
    MXPI_PIXEL_FORMAT_YVU_SEMIPLANAR_422 = 4, // 4, YUV422SP NV21 8bit
    MXPI_PIXEL_FORMAT_YUV_SEMIPLANAR_444 = 5, // 5, YUV444SP NV12 8bit
    MXPI_PIXEL_FORMAT_YVU_SEMIPLANAR_444 = 6, // 6, YUV444SP NV21 8bit
    MXPI_PIXEL_FORMAT_YUYV_PACKED_422 = 7, // 7, YUV422P YUYV 8bit
    MXPI_PIXEL_FORMAT_UYVY_PACKED_422 = 8, // 8, YUV422P UYVY 8bit
    MXPI_PIXEL_FORMAT_YVYU_PACKED_422 = 9, // 9, YUV422P YVYU 8bit
    MXPI_PIXEL_FORMAT_VYUY_PACKED_422 = 10, // 10, YUV422P VYUY 8bit
    MXPI_PIXEL_FORMAT_YUV_PACKED_444 = 11, // 11, YUV444P 8bit
    MXPI_PIXEL_FORMAT_RGB_888 = 12,        // 12, RGB888 8bit
    MXPI_PIXEL_FORMAT_BGR_888 = 13,        // 13, BGR888 8bit
  • The width and height of an 8K image range from 32 to 8192. The width and height of a 4K image range from 32 to 4096.

Plugin Base Class (Factory)

mxpi_imageresize

Input/Output

Input: buffer (data type: MxpiBuffer) and metadata (data type: MxpiVisionList)

Output: buffer (data type: MxpiBuffer) and metadata (data type: MxpiVisionList)

Port Format (Caps)

Static input: {"image/yuv","metadata/object","image/rgb"}

Static output: {"image/yuv","image/rgb"}

Property

For details, see Table 1.

Table 1 mxpi_imageresize plugin properties

Property Name

Description

Mandatory or Not

Modifiable or Not

deviceId

Ascend device ID, which is specified by the deviceId property in the stream_config field. You do not need to set the ID.

No

Yes

removeParentData

Whether to remove the original buffer data. The default value is no.

Yes

Yes

parentName

Index of the input data (generally the name of the upstream element). The function is the same as that of dataSource. dataSource is recommended because parentName will be deleted in later versions.

Do not use it.

Yes

dataSource

Index of the input data (generally the name of the upstream element). The default value is the key value of the output port of the upstream plugin.

Recommended

Yes

resizeHeight

  • Height after resizing in Resizer_Stretch and Resizer_KeepAspectRatio_Fit resizing modes. By default, the image height of the downstream model inference plugin is automatically adapted. The value range is [6,4096].
  • The height after resizing is automatically 2-pixel aligned. You are advised to set the height of the scaled image to 2-pixel aligned and ensure that it is within [1/32,16] of the height in the image resolution.
  • If the downstream of the scaling plugin is not an inference plugin, the scaling width and height must be set. If the downstream of the scaling plugin is an inference plugin, you do not need to set the scaling width and height, which can be automatically obtained.

No

Yes

resizeWidth

  • Width after resizing in Resizer_Stretch and Resizer_KeepAspectRatio_Fit resizing modes. By default, the image width of the downstream model inference plugin is automatically adapted. The value range is [32,4096].
  • The width after resizing is automatically 16-pixel aligned. You are advised to set the width of the scaled image to 16-pixel aligned and ensure that it is within [1/32,16] of the width in the image resolution.
  • If the downstream of the scaling plugin is not an inference plugin, the scaling width and height must be set. If the downstream of the scaling plugin is an inference plugin, you do not need to set the scaling width and height, which can be automatically obtained.

No

Yes

maxDimension

Maximum length of the resized image in Fast R-CNN resizing mode

No

Yes

minDimension

Minimum length of the resized image in Fast R-CNN resizing mode

No

Yes

resizeType

Resizing mode:

  • Resizer_Stretch: indicates the stretch mode, which is the default resizing mode. OpenCV and Ascend modes are supported.
  • Resizer_KeepAspectRatio_FastRCNN: corresponds to the Fast R-CNN resizing mode. OpenCV and Ascend modes are supported.
  • Resizer_KeepAspectRatio_Fit: resizes the image proportionally to maximize the image area within the specified width and height. OpenCV and Ascend modes are supported.
  • Resizer_OnlyPadding: supports padding only. OpenCV and Ascend are supported.
  • Resizer_KeepAspectRatio_Long: proportionally resizes the maximum edge to a specified value. Only OpenCV is supported.
  • Resizer_KeepAspectRatio_Short: proportionally resizes the minimum edge to a specified value. Only OpenCV is supported.
  • Resizer_Rescale: performs the resizing proportionally based on the smaller ratio of the length and width. Only OpenCV is supported.
  • Resizer_Rescale_Double: performs the resizing proportionally based on the smaller ratio of the length and width twice. Only OpenCV is supported.
  • Resizer_PaddleOCR: performs height-based proportional resizing. Only OpenCV is supported.
  • Resizer_MS_Yolov4: indicates the resizing mode corresponding to the YOLOv4 model. Only OpenCV is supported.

No

Yes

scaleValue

Resizer_KeepAspectRatio_Long: resizes the maximum edge to a specified value.

Resizer_KeepAspectRatio_Short: resizes the minimum edge to a specified value.

Yes

Yes

RGBValue

Padding color value. Enter the R, G, and B values in sequence. By default, the padding color is not set, and the default background color of DVPP is used. Only Ascend is supported.

No

Yes

interpolation

Interpolation mode of the resize plugin. The default value is 0.

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 inference products:
  • 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.

No

Yes

cvProcessor

Processing mode. For details about the differences, see Before You Start.
  • Ascend (default)
  • OpenCV

No

Yes

paddingType

Padding mode:

  • Padding_NO (default): no padding (for both Ascend and OpenCV).
  • Padding_RightDown: padding in the lower right corner (for OpenCV only).
  • Padding_Around: padding in the upper, lower, left, and right corner (for both Ascend and OpenCV).

No

Yes

paddingHeight

Height of the padded image, which must be greater than the height of the scaled image. (This property takes effect only in OpenCV processing.)

No

Yes

paddingWidth

Width of the padded image, which must be greater than the width of the scaled image. (This property takes effect only in OpenCV processing.)

No

Yes

paddingColorB

Color blue of the padded image. The value can be a floating point number ranging from 0 to 255. Only OpenCV is supported.

No

Yes

paddingColorG

Color green of the padded image. The value can be a floating point number ranging from 0 to 255. Only OpenCV is supported.

No

Yes

paddingColorR

Color red of the padded image. The value can be a floating point number ranging from 0 to 255. Only OpenCV is supported.

No

Yes