Updated on 2022-02-22 GMT+08:00

Cropping Images

This API is used to crop an image.

  • API calling

    hilens.Preprocessor.crop(src, x, y, w, h, t)

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Type

    Description

    src

    Yes

    <class'numpy.ndarray'> object

    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.

    x

    Yes

    Positive integer

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

    y

    Yes

    Positive integer

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

    w

    Yes

    Positive integer

    Width of the image after cropping. Value range: [64, 1920], a multiple of 2.

    h

    Yes

    Positive integer

    Height of the image after cropping. Value range: [64, 1080], a multiple of 2.

    t

    Yes

    Integer 0 or 1

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

  • Return value

    If the crop operation is successful, the resized image is returned, which is a <class'numpy.ndarray'> object.

    If the crop operation fails, "ValueError" is reported.