Updated on 2023-06-15 GMT+08:00

Cropping Images

This section describes how to crop an image.

API Calling

HiLensEC hilens::Preprocessor::Crop(const cv::Mat & src, cv::Mat & dst, unsigned int x, unsigned int y, unsigned int w, unsigned int h, int type = 0)

Parameter Description

Table 1

Parameter

Description

src

Source image, which must be in the NV21 format. Width range: [64, 1920], a multiple of 2; Height range: [64, 1080], a multiple of 2.

If the input is not in the NV21 format, convert the input source image to the NV21 format. Refer to Converting the Image Color Format for details.

dst

Target image

x

X coordinate in the upper left corner of the cropped area. Value range: [0, 1920], a multiple of 2.

y

Y coordinate in the upper left corner of the cropped area. Value range: [0, 1080], a multiple of 2.

w

Width of the image after zoom-in/out. Value range: [64, 1920], a multiple of 2.

h

Height of the image after zoom-in/out. Value range: [64, 1080], a multiple of 2.

type

Format of the target image. The value 0 indicates NV21, and value 1 indicates NV12. The default value is 0.

Return Value

If the return value is 0, the operation is successful. Otherwise, the operation fails. Refer to Error Codes for details about the failure response parameters.