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

视频分类

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

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

简介

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

C接口说明

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

1.创建视频分类句柄

BEF_SDK_API bef_effect_result_t
bef_effect_ai_video_cls_create(bef_effect_handle_t *handle);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t创建的视频分类句柄

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

2.加载模型

BEF_SDK_API bef_effect_result_t
bef_effect_ai_video_cls_load_model(bef_effect_handle_t handle,
                                   bef_ai_video_cls_model_type type,
                                   const char * strModelPath);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t创建的视频分类句柄
typebef_ai_video_cls_model_type模型类型枚举
strModelPathconst char *模型路径

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

2.进行视频分类

BEF_SDK_API bef_effect_result_t
bef_effect_ai_video_cls_detect(
                             bef_effect_handle_t handle,
                             const unsigned char *image,
                             bef_ai_pixel_format pixel_format,
                             int image_width,
                             int image_height,
                             int image_stride,
                             bef_ai_rotate_type orientation,
                             bool islast,
                             bef_video_cls_ret *video_cls_info
                             );

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t视频分类句柄
imageconst unsigned char *模型类型,目前分大小模型
pixel_formatbef_ai_pixel_format模型文件的路径
image_widthint图片宽度
image_heightint图片高度
image_strideint图片步长
orientationbef_ai_rotate_type图片的旋转方向
islastbool是否是最后一帧(每5帧设置成true)
resultbef_video_cls_ret分类结果,具体参考 bef_video_cls_ret

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

3.释放句柄

BEF_SDK_API void
bef_effect_ai_video_cls_destroy(
                              bef_effect_handle_t handle
                              );

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t视频分类句柄

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

4.视频分类授权

// android
BEF_SDK_API bef_effect_result_t
bef_effect_ai_video_cls_check_license(
        JNIEnv* env,
        jobject context,
        bef_effect_handle_t handle,
        const char *licensePath
        );
// ios
BEF_SDK_API bef_effect_result_t
bef_effect_ai_video_cls_check_license(
        bef_effect_handle_t handle,
        const char *licensePath
        );

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t视频分类句柄
licensePathconst char *授权文件字符串
contextjobject对应 Android 中的 Context

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

Java 接口说明

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

1.初始化视频分类句柄

public int createHandle(
    Context context, String licensePath)

参数说明

参数名参数类型参数说明
contextContext应用上下文
licenseString授权文件路径

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

2.进行视频分类

public BefVideoClsInfo videoClsDetect(
        ByteBuffer buffer,
        BytedEffectConstants.PixlFormat pixlFormat,
        int imageWidth,
        int imageHeight,
        int imageStride,
        BytedEffectConstants.Rotation orientation
        boolean  isLast) 

参数说明

参数名参数类型参数说明
bufferByteBuffersdk设置参数类型
pixlFormatBytedEffectConstants.PixlFormatsdk设置参数值
imageWidthint图片宽度
imageHeightint图片高度
imageStrideint图片步长
orientationBytedEffectConstants.Rotation图片旋转方向
boolisLast是否是最后一帧(每5帧设置成true)

备注

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 void release()

FAQ

错误码

错误码请参考错误码表