CropResize
Function Usage
Image cropping and resizing API of the ImageProcessor class. The memory allocated by this API does not need to be managed or destroyed by users.
- For details about the input and output image formats of the Image class, see ImageFormat.
- The original width and height of the input Image class range from 18 x 6 to 4096 x 4096. For images in YUV_SP_420 and YVU_SP_420 formats, the width and height can be 8192 x 8192.
- The maximum resolution of the output Image class is 4096 x 4096 and the minimum resolution is 18 x 6.
- The width of the output image automatically becomes a multiple of 16, and the height becomes a multiple of 2. Therefore, the width and height range from 32 x 6 to 4096 x 4096.
- The minimum size of the cropping ROI is 10 x 6. The width and height of the cropping ROI cannot exceed those of the input image.
- The resizing range is 18 x 6 to 4096 x 4096 and cannot exceed a multiple of [1/32, 16] of the cropping ROI.
- Due to hardware interface restrictions, it is recommended that the four values of cropRect be even numbers. If odd numbers are included, 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.
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.
Prototype
APP_ERROR CropResize(const Image& inputImage, const std::vector<Rect>& cropRectVec,
const Size& resize, std::vector<Image>& outputImageVec);
APP_ERROR CropResize(const Image& inputImage, const std::vector<std::pair<Rect, Size>>& cropResizeVec,
std::vector<Image>& outputImageVec);
APP_ERROR CropResize(const std::vector<Image>& inputImageVec,
const std::vector<std::pair<Rect, Size>>& cropResizeVec,
std::vector<Image>& outputImageVec);
Parameter Description
Parameter |
Input/Output |
Description |
|---|---|---|
inputImage |
Input |
Image class before cropping and resizing. The Image classes 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 in a batch). The Image classes 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 in a batch). |
Return Parameter Description
Data Structure |
Description |
|---|---|
APP_ERROR |
Error code returned during program execution. For details, see the MxBase/ErrorCode/ErrorCode.h file. |