vpc_crop_resize_make_border

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas training product

x

Atlas inference product

Atlas 200I/500 A2 inference product

Description

Crops one or more ROIs from an image, resizes the crop ROIs, and then pads each ROI based on the specific type to form one or more destination images. This API is mainly used for resizing with the aspect ratio preserved. This API is asynchronous.

Prototype

  • C Prototype
    1
    hi_s32 hi_mpi_vpc_crop_resize_make_border(hi_vpc_chn chn, const hi_vpc_pic_info *source_pic, hi_vpc_crop_resize_border_region crop_resize_make_border_info[], hi_u32 count, hi_u32 *task_id, hi_s32 milli_sec);
    
  • Python Function
    1
    task_id, ret = acl.himpi.vpc_crop_resize_make_border(chn, source_pic, crop_resize_make_border_info, count, milli_sec)
    

Parameters

Parameter

Description

chn

Int, channel ID for image processing.

source_pic

Dict, source image information. For details, see hi_vpc_pic_info. For details about related restrictions, see Restrictions.

crop_resize_make_border_info

List, list of images for cropping, resizing, and padding. You need to set the cropping, resizing, and padding information as well as the memory address of the destination image. VPC stores the result data after cropping, resizing, and padding in the specified memory address. For details, see hi_vpc_crop_resize_border_region.

If the data of multiple padding results points to the same buffer address, the data of the later result overwrites that of the previous one. Consequently, the output image is inconsistent with the desired image.

Currently, only the HI_BORDER_CONSTANT and HI_BORDER_REPLICATE types are supported, which allow padding to 4096 x 4096. The length of the crop_resize_make_border_info array must be the same as that of the count value.

count

Int, number of crop, resize, and padding ROIs. Must be in the range of [1, 256].

milli_sec

Int, timeout interval, in milliseconds.

Return Value

Return Value

Description

task_id

Int, task ID, used to identify a task.

ret

Int, error code.
  • 0 indicates success.
  • Other values indicate failure. For details, see VPC Return Codes.

Restrictions

Version

Restrictions

Atlas inference product

  • Input image size and format:
    • When the input image size is in the range of [10 x 6, 4096 x 4096], the input image formats described in Restrictions on Image Formats, Width and Height Alignment, and Buffers are supported.
    • When the input image width or height is in the range of (4096, 8192], the supported formats are as follows:
      The following enum values of hi_pixel_format are supported:
      HI_PIXEL_FORMAT_YUV_400 = 0,               // YUV400 8bit
      HI_PIXEL_FORMAT_YUV_SEMIPLANAR_420 = 1,    // YUV420SP NV12 8bit   
      HI_PIXEL_FORMAT_YVU_SEMIPLANAR_420 = 2,    // YUV420SP NV21 8bit 
      HI_PIXEL_FORMAT_YUV_SEMIPLANAR_422 = 3,    // YUV422SP 8bit
      HI_PIXEL_FORMAT_YVU_SEMIPLANAR_422 = 4,    // YVU422SP 8bit
      HI_PIXEL_FORMAT_YUV_SEMIPLANAR_444 = 5,    // YUV444SP 8bit
      HI_PIXEL_FORMAT_YVU_SEMIPLANAR_444 = 6,    // YVU444SP 8bit
      HI_PIXEL_FORMAT_YUYV_PACKED_422 = 7,       // YUV422Packed YUYV 8bit
      HI_PIXEL_FORMAT_UYVY_PACKED_422 = 8,       // YUV422Packed UYVY 8bit
      HI_PIXEL_FORMAT_YVYU_PACKED_422 = 9,       // YUV422Packed YVYU 8bit
      HI_PIXEL_FORMAT_VYUY_PACKED_422 = 10,      // YUV422Packed VYUY 8bit
    • For details about the restrictions on the width and height alignment and buffer size of each image format, see Restrictions on Image Formats, Width and Height Alignment, and Buffers.
  • For details about the restrictions on the output image size, image format, width and height alignment, and buffer size, see Restrictions.
  • When the input and output images are in ARGB8888, ABGR8888, RGBA8888, or BGRA8888 format, the A component value changes to 0 after being processed by this API.
  • hi_vpc_crop_resize_border_region allows diversified setting combinations. However, if the desired size for resizing is the same as the crop ROI size, resizing is not performed. If the offset values are 0, padding is not performed.
  • For details about the API description and restrictions, see Restrictions on Image Cropping and Pasting.
  • Due to restrictions on downsampling of YUV images, pay attention to the following when the output image format is YUV420SP or YUV422SP:
    • For the YUV420SP output format, it is recommended that the border lengths at the top, bottom, left, and right of the image be even numbers.
    • For the YUV422SP output format, it is recommended that the border lengths at the left and right of the image be even numbers.

Atlas 350 Accelerator Card

Atlas 200I/500 A2 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas A3 training product/Atlas A3 inference product

  • For details about the restrictions on the image size, image format, width and height alignment, and buffer size, see Restrictions.
  • To specify the fx and fy pair, ensure that the destination image size is in the range of [10 × 6, 16384 × 16384]. Otherwise, an error code is returned.
  • When the input and output images are in ARGB8888, ABGR8888, RGBA8888, or BGRA8888 format, the A component value changes to 0 after being resized by this API.
  • hi_vpc_crop_resize_border_region allows diversified setting combinations. However, if the desired size for resizing is the same as the crop ROI size, resizing is not performed. If the offset values are 0, padding is not performed.
  • For details about the API description and restrictions, see Restrictions on Image Cropping and Pasting.
  • Due to restrictions on downsampling of YUV images, pay attention to the following when the output image format is YUV420SP or YUV422SP:
    • For the YUV420SP output format, it is recommended that the border lengths at the top, bottom, left, and right of the image be even numbers.
    • For the YUV422SP output format, it is recommended that the border lengths at the left and right of the image be even numbers.