Crop

Function Usage

Image cropping 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 effect, see Figure 1.

For details, see Cropping.

Figure 1 Cropping

Prototype

Prototype 1:

1
APP_ERROR ImageProcessor::Crop(const Image& inputImage, const Rect& cropRect, Image& outputImage, AscendStream& stream = AscendStream::DefaultStream());

Prototype 2:

1
APP_ERROR ImageProcessor::Crop(const Image& inputImage, const std::vector<Rect>& cropRectVec, std::vector<Image>& outputImageVec, AscendStream& stream = AscendStream::DefaultStream());

Prototype 3:

1
APP_ERROR ImageProcessor::Crop(const std::vector<Image>& inputImageVec, const std::vector<Rect>& cropRectVec, std::vector<Image>& outputImageVec, AscendStream& stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

inputImage

Input

Image class before cropping.

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 image width and height.

inputImageVec

Input

List of the Image class before cropping (application scenario: image cropping in a batch).

cropRect

Input

Coordinates for image cropping

cropRectVec

Input

List of coordinates for image cropping (application scenario: image cropping in a batch).

outputImage

Output

Image class after cropping.

outputImageVec

Output

List of the Image class after cropping (application scenario: image cropping 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.