You need to enable JavaScript to run this app.
导航
脏镜头检测
最近更新时间:2025.03.17 14:05:34首次发布时间:2025.03.17 14:05:34
我的收藏
有用
有用
无用
无用
简介

脏镜头检测提供了一套在拍摄前判断镜头是否脏污的解决方案,从源头上防止因镜头脏污而产生的低质视频,给用户的拍摄提供更强的保障。
V4.4.2及之后版本新增算法,iOS11以下机器不支持除画质模块除插帧外的算法。

技术规格
支持平台Android、iOS
支持输入格式BGR888
内存占用<11.99M (测试设备OPPO R11)
检测速度<3.29ms(测试设备OPPO R11)
C接口说明

双端接口非线程安全,需要保证单线程进行算法的创建、执行和销毁。详细接口说明查看头文件:bef_ai_image_quality_enhancement_taint_detect.h

1.创建脏镜头检测算法句柄

BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_taint_detect_create(
    bef_image_quality_enhancement_handle *handle, 
    bef_ai_taint_scene_detect_param *param);

typedef struct bef_ai_taint_scene_detect_param {
    int detectFrequency;
    const char* modelPath;
    const char* kernelBinPath;
    bef_ai_lens_backend_type backendType;
    int numThread; // only make sense when backendType is CPU, default set 2
}bef_ai_taint_scene_detect_param;

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle*创建的脏镜头检测算法句柄
configbef_ai_taint_scene_detect_param*算法初始化时的配置参数

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

2.脏镜头检测算法执行

注意:
算法输入要求为宽高224的BGR小图,小图不能是使用crop后丢失了内容的图像,必须是scale出来的小图。
switchScene表示如果算法实例是复用的话,每次检测一开始第一帧设置下true,第二帧及以后就是false了。相当于,把以前检测结果缓存的信息给reset掉。如果每次检测启动一个算法实例,这里不用配置这个逻辑,直接设置成false即可。

BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_taint_detect_process(
    bef_image_quality_enhancement_handle handle, 
    bef_ai_taint_scene_detect_buffer *input, 
    float *score);

typedef struct bef_ai_taint_scene_detect_buffer {
    void *inBuffer;
    bool switchScene;
}bef_ai_taint_scene_detect_buffer;

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle脏镜头检测算法句柄
inputbef_ai_taint_scene_detect_buffer*脏镜头检测算法输入
scorefloat*脏镜头概率输出

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

3.释放句柄

BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_taint_detect_destroy(
    bef_image_quality_enhancement_handle handle);

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle脏镜头检测算法句柄

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

4.脏镜头检测算法授权

// 离线license检测方式
BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_taint_detect_check_license(
    bef_image_quality_enhancement_handle handle, 
    const char* licensePath);

// 在线license检测方式
BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_taint_detect_check_online_license(
    bef_image_quality_enhancement_handle handle, 
    const char* licensePath)

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle脏镜头检测算法句柄
licensePathconst char *授权文件路径

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

Java 接口说明

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

1.初始化脏镜头检测句柄

public int init(
    Context context, 
    TaintDetectParam param,
    String licensePath, 
    boolean onlineLicense);

参数说明

参数名参数类型参数说明
contextContext安卓context
paramTaintDetectParam脏镜头检测参数
licensePathString授权文件路径
onlineLicenseboolean配置在线授权或离线授权

返回值
成功返回BEF_RESULT_SUC,否则返回对应的错误码
备注
关于TaintDetectParam可参考com.bytedance.labcv.effectsdk.TaintSceneDetect.java,并且其定义与C接口bef_ai_image_quality_enhancement_taint_detect保持一致。

2.脏镜头检测算法处理

public float process(
    ByteBuffer buffer);

参数说明

参数名参数类型参数说明
bufferByteBuffer输入buffer

返回值
返回脏镜头判断概率值

3.释放脏镜头检测句柄

public void release()
FAQ

1.如果出现任何异常,请查看是否有以下类型日志

答:建议首先查看以下tag输出Error类型的日志:
bef_effect_ai 和SMASH_E_LOG 以及 EffectSDK

错误码

错误码请参考错误码表