You need to enable JavaScript to run this app.
导航

C2

最近更新时间2023.06.28 14:42:05

首次发布时间2022.02.25 17:16:51

简介

C2 场景分类SDK提供对视频内容实时分类的能力,支持识别 122 种不同的场景类型。

C接口说明

详细接口说明查看头文件:bef_effect_ai_c2.h

1.创建场景分类句柄

BEF_SDK_API
bef_effect_result_t bef_effect_ai_c2_create(bef_ai_c2_handle *handle);

参数说明

参数名参数类型参数说明
handlebef_ai_c1_handle创建的场景分类句柄

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

2.设置模型

BEF_SDK_API
bef_effect_result_t bef_effect_ai_c2_set_model(bef_ai_c2_handle handle, bef_ai_c2_model_type type, const char *modelPath);

参数说明

参数名参数类型参数说明
handlebef_ai_c2_handle创建的场景分类句柄
modelTypebef_ai_c2_model_type模型类型
modelPathconst char *模型路径

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

3.设置参数

BEF_SDK_API
bef_effect_result_t bef_effect_ai_c2_set_paramF(bef_ai_c2_handle handle, bef_ai_c2_param_type type, float value);

BEF_SDK_API
bef_effect_result_t bef_effect_ai_c2_set_paramS(bef_ai_c2_handle handle, bef_ai_c2_param_type type, char *value);

参数说明

参数名参数类型参数说明
handlebef_ai_c2_handle创建的场景分类句柄
typebef_ai_c2_param_type参数类型
valuefloat/char *参数值

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

4.进行场景分类

BEF_SDK_API
bef_effect_result_t bef_effect_ai_c2_detect(bef_ai_c2_handle handle,
                                            const unsigned char *image,
                                            bef_ai_pixel_format pixelFormat,
                                            int imageWidth,
                                            int imageHeight,
                                            int imageStride,
                                            bef_ai_rotate_type rotation,
                                            bef_ai_c2_ret *result);

参数说明

参数名参数类型参数说明
handlebef_ai_c2_handle场景分类句柄
imageconst unsigned char *模型类型
pixelFormatbef_ai_pixel_format模型文件的路径
imageWidthint图片宽度
imageHeightint图片高度
imageStrideint图片步长
orientationbef_ai_rotate_type图片的旋转方向
resultbef_ai_c2_ret分类结果,具体参考 bef_ai_c2_ret

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

5.释放句柄

BEF_SDK_API
bef_effect_result_t bef_effect_ai_c2_release(bef_ai_c2_handle handle);

参数说明

参数名参数类型参数说明
handlebef_ai_c2_handle场景分类句柄

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

6.初始化检测结果

BEF_SDK_API
bef_ai_c2_ret *bef_effect_ai_c2_init_ret(bef_ai_c2_handle handle);

参数说明**

参数名参数类型参数说明
handlebef_ai_c2_handle场景分类句柄

返回值
返回 bef_ai_c2_ret 指针。

7.释放检测结果

BEF_SDK_API
bef_effect_result_t bef_effect_ai_c2_release_ret(bef_ai_c2_handle handle, bef_ai_c2_ret *ret);

参数说明**

参数名参数类型参数说明
handlebef_ai_c2_handle场景分类句柄
retbef_ai_c2_ret返回结果

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

8.光线检测授权

BEF_SDK_API
bef_effect_result_t bef_effect_ai_c1_check_license(bef_ai_c1_handle handle, const char *licensePath);

参数说明

参数名参数类型参数说明
handlebef_ai_c1_handle场景分类句柄
licensePathconst char *授权文件字符串

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

Java 接口说明

接口说明
详细接口说明查看文件:com.bytedance.labcv.effectsdk.C2Detect

1.初始化场景分类句柄

public int init(BytedEffectConstants.C2ModelType modelType,
                String modelPath, 
                String licensePath)

参数说明

参数名参数类型参数说明
modelTypeBytedEffectConstants.C2ModelType模型类型
modelPathString模型路径
licensePathString授权文件路径

返回值
成功返回BEF_RESULT_SUC,否则返回对应的错误码

2.进行场景分类

public BefC2Info detect(ByteBuffer buffer, 
                        BytedEffectConstants.PixlFormat pixelFormat,
                        int imageWidth, 
                        int imageHeight, 
                        int imageStride,
                        BytedEffectConstants.Rotation orientation)

参数说明

参数名参数类型参数说明
bufferByteBuffersdk设置参数类型
pixlFormatBytedEffectConstants.PixlFormatsdk设置参数值
imageWidthint图片宽度
imageHeightint图片高度
imageStrideint图片步长
orientationBytedEffectConstants.Rotation图片旋转方向

备注

BytedEffectConstants.PixlFormat 见:

public enum PixlFormat {
    RGBA8888(0),
    BGRA8888(1),
    BGR888(2),
    RGB888(3),
    BEF_AI_PIX_FMT_YUV420P(5),
    BEF_AI_PIX_FMT_NV12(6),
    BEF_AI_PIX_FMT_NV21(7);
    private int value;
    PixlFormat(int value) {
        this.value = value;
    }
    public int getValue() {
        return value;
    }
}

BytedEffectConstants.Rotation 见:

public enum Rotation {
    /**
     * 图像不需要旋转,图像中的人脸为正脸
     * The image does not need to be rotated. The face in the image is positive
     */
    CLOCKWISE_ROTATE_0(0),
    /**
     * 图像需要顺时针旋转90度,使图像中的人脸为正
     * The image needs to be rotated 90 degrees clockwise so that the face in the image is positive
     */
    CLOCKWISE_ROTATE_90(1),
    /**
     * 图像需要顺时针旋转180度,使图像中的人脸为正
     * The image needs to be rotated 180 degrees clockwise so that the face in the image is positive
     */
    CLOCKWISE_ROTATE_180(2),
    /**
     * 图像需要顺时针旋转270度,使图像中的人脸为正
     * The image needs to be rotated 270 degrees clockwise so that the face in the image is positive
     */
    CLOCKWISE_ROTATE_270(3);
    public int id = 0;
    Rotation(int id) {
        this.id = id;
    }
}

返回值
成功返回BEF_RESULT_SUC,否则返回对应的错误码

3. 设置参数

public int setParam(BytedEffectConstants.C2ParamType paramType, float value)

参数说明

参数名参数类型参数说明
paramTypeBytedEffectConstants.C1ParamType参数类型
valuefloat参数值

返回值
成功返回BEF_RESULT_SUC,否则返回对应的错误码

4.释放句柄

public void release()

FAQ

错误码

错误码请参考错误码表