Help Center/ Huawei HiLens/ Developer Guide/ Preprocessing Module/ Converting the Image Color Format
Updated on 2022-02-22 GMT+08:00

Converting the Image Color Format

This API is used to convert the image color format. The native OpenCV does not provide the option of converting RGB/BGR to NV12/NV21.

  • API calling

    hilens.cvt_color(src, code)

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Type

    Description

    src

    Yes

    <class'numpy.ndarray'> object

    Source image (BGR888 or RGB888)

    code

    Yes

    Enumeration type. Options: {RGB2YUV_NV12, RGB2YUV_NV21, BGR2YUV_NV12, BGR2YUV_NV21}.

    Conversion type

  • Return value

    <class'numpy.ndarray'> object, converted image (NV12 or NV21). If the conversion fails, an empty numpy.ndarray object is returned.