CropResize
Function Usage
Image cropping and 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 cropping and resizing effect, see Figure 1.
For details, see Cropping and 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 size range is [18 x 6, 4096 x 4096]. The size of YUV_SP_420 or YVU_SP_420 image can reach 8192 x 8192.
- The minimum size of the cropped ROI is 10 x 6. The width and height of the cropped region cannot exceed the actual width and height of the input image. It is recommended that the four coordinates of cropRect be even numbers. If odd numbers are included (excluding RGB and BGR formats), the coordinate of the upper left corner is automatically rounded down to an even number, and the coordinate of the lower right corner is automatically rounded up to an even number.
- The maximum resolution of the output Image class is 4096 x 4096 and the minimum resolution is 18 x 6. For example, if cropRect is set to {1, 1, 1287, 1287}, the actual width and height of the cropped image are ((1287 + 1) - (1 - 1)) = 1288, and the resolution is 1288 x 1288.
- The resizing range is 18 x 6 to 4096 x 4096 and cannot exceed a multiple of [1/32, 16] of the cropping ROI.
- In the outputImageVec, the width of each image is a multiple of 16, and the height is a multiple of 2. The value range is [32 × 6, 4096 × 4096].
Prototype
Prototype 1:
1
|
APP_ERROR ImageProcessor::CropResize(const Image& inputImage, const std::vector<Rect>& cropRectVec, const Size& resize, std::vector<Image>& outputImageVec, AscendStream& stream = AscendStream::DefaultStream()); |
Prototype 2:
1
|
APP_ERROR ImageProcessor::CropResize(const Image& inputImage, const std::vector<std::pair<Rect, Size>>& cropResizeVec, std::vector<Image>& outputImageVec, AscendStream& stream = AscendStream::DefaultStream()); |
Prototype 3:
1
|
APP_ERROR ImageProcessor::CropResize(const std::vector<Image>& inputImageVec, const std::vector<std::pair<Rect, Size>>& cropResizeVec, std::vector<Image>& outputImageVec, AscendStream& stream = AscendStream::DefaultStream()); |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
inputImage |
Input |
Image class before cropping and 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. |
|
inputImageVec |
Input |
List of the Image class before cropping and resizing (application scenario: image cropping and resizing in a batch). 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. |
|
cropRectVec |
Input |
List of cropping parameters. The number must be the same as that of elements in the output image list. |
|
resize |
Input |
Width and height for resizing. |
|
cropResizeVec |
Input |
List of cropping and resizing parameters. Rect indicates the coordinates for image cropping and Size indicates the height and width for resizing (application scenario: image cropping and resizing in a batch). |
|
outputImageVec |
Output |
List of the Image class after cropping (application scenario: image cropping and resizing in a batch). |
|
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. |
