版本4.1.0.3上架算法,注意iOS11以下的机器不支持除插帧外的画质相关算法。
自适应锐化算法的基本目标:
支持平台 | Android、iOS |
---|---|
支持输入格式 | Android:2d纹理; iOS:yuv420p,420f的pixelbuffer |
内存占用 | <34M (测试设备OPPO R11) |
检测速度 | <13ms(测试设备OPPO R11) |
详细接口说明查看头文件:bef_ai_image_quality_enhancement_adaptive_sharpen.h
BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_adaptive_sharpen_create(bef_image_quality_enhancement_handle* handle, const bef_ai_asf_init_config* config);
typedef struct bef_ai_asf_init_config{
bef_ai_asf_scene_mode scene_mode; //场景模式
void* context; //iOS端可以传入外部metal device,如果为nullptr,则在lens内部新建device
#if defined(__ANDROID__) || defined(TARGET_OS_ANDROID)
bef_ai_lens_power_level level; //iOS端无需设置
#endif
bef_ai_lens_data_type input_type; // 输入数据的类型
bef_ai_lens_data_type output_type; // 输出数据的类型
int frame_width;//视频宽度
int frame_height;//视频高度
float amount;//锐化强度增益,默认-1(无效值),即不调整。 有效值为>0:当设置>1时,会增大锐化强度,设置<1时,减弱锐化强度。
float over_ratio;//黑白边的容忍度增益,默认-1(无效值),即不调整。有效值为>0:当amount>1时,如果发现增大amount清晰度没有明显增加,可能需要稍微增大over_ratio,经验公式为:over_ratio= 1+ a * (amount -1),其中比例系数a可调整,属于0~1范围。
float edge_weight_gamma;//对中低频边缘的锐化强度进行调整, 默认-1(无效值),即 不调整。有效值为>0
int diff_img_smooth_enable;//开启后减少锐化带来的边缘artifacts,但锐化强度会比关闭时弱一些, 默认-1(无效值),即保持内部设置,目前设置为开启。 有效值为0或1,0--关闭,1--开启
}bef_ai_asf_init_config;
c
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle* | 创建的自适应锐化算法句柄 |
config | bef_ai_asf_init_config* | 算法初始化时的配置参数 |
返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_adaptive_sharpen_set_property(bef_image_quality_enhancement_handle handle, const bef_ai_asf_property* config);
typedef struct bef_ai_asf_property{
bef_ai_asf_scene_mode scene_mode; //场景模式
int frame_width;//视频宽度
int frame_height;//视频高度
float amount;//锐化强度增益,默认-1(无效值),即不调整。 有效值为>0:当设置>1时,会增大锐化强度,设置<1时,减弱锐化强度。
float over_ratio;//黑白边的容忍度增益,默认-1(无效值),即不调整。有效值为>0:当amount>1时,如果发现增大amount清晰度没有明显增加,可能需要稍微增大over_ratio,经验公式为:over_ratio= 1+ a * (amount -1),其中比例系数a可调整,属于0~1范围。
float edge_weight_gamma;//对中低频边缘的锐化强度进行调整, 默认-1(无效值),即 不调整。有效值为>0
int diff_img_smooth_enable;//开启后减少锐化带来的边缘artifacts,但锐化强度会比关闭时弱一些, 默认-1(无效值),即保持内部设置,目前设置为开启。 有效值为0或1,0--关闭,1--开启
}bef_ai_asf_property;
c
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 自适应锐化算法句柄 |
config | bef_ai_asf_property* | 输入参数属性 |
返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_adaptive_sharpen_process(bef_image_quality_enhancement_handle handle, const bef_ai_asf_input* input, bef_ai_asf_output *output);
typedef struct bef_ai_asf_input{
bef_ai_lens_data data; // 输入数据的数据
bef_ai_lens_data_type type;// 输入数据格式
}bef_ai_asf_input;
typedef struct bef_ai_asf_output{
bef_ai_lens_data data; // 输出类型数据,会根据输入,填充对应的输出部分
bef_ai_lens_data_type type;// 输出数据格式
}bef_ai_asf_output;
c
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 自适应锐化算法句柄 |
config | bef_ai_asf_input* | 自适应锐化算法输入 |
input | bef_ai_asf_output* | 自适应锐化算法输出 |
返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_adaptive_sharpen_destory(bef_image_quality_enhancement_handle handle);
c
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 自适应锐化算法的句柄 |
返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
// 离线license检测方式
BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_adaptive_sharpen_check_license(bef_image_quality_enhancement_handle handle, const char* license_path);
// 在线license检测方式
BEF_SDK_API bef_effect_result_t
bef_ai_image_quality_enhancement_adaptive_sharpen_check_online_license(bef_image_quality_enhancement_handle handle, const char* license_path);
c
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 自适应锐化算法句柄 |
licensePath | const char * | 授权文件路径 |
返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
接口说明
详细接口说明查看文件:com.bytedance.labcv.effectsdk.AdaptiveSharpen.java
public int init(
String licensePath,
int maxHeight,
int maxWidth,
int mode,
int level,
float amount,
float overRatio,
float edgeWeightGamma,
int diffImgSmoothEnable,
boolean onlineLicense)
java
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
licensePath | String | 授权文件绝对路径 |
maxHeight | int | 视频高度 |
maxWidth | int | 视频宽度 |
mode | int | 场景模式 |
level | int | 传入频率设置等级,默认为auto等级(default是指随系统调节,low是使用低频率,normal是使用中频率,high是使用高频率,auto是sdk内部根据机型自动调节 |
amount | float | 锐化强度增益,默认-1(无效值),即不调整。有效值为>0:当设置>1时,会增大锐化强度,设置<1时,减弱锐化强度。 |
overRatio | float | 黑白边的容忍度增益,默认-1(无效值),即不调整 |
edgeWeightGamma | float | 对中低频边缘的锐化强度进行调整, 默认-1(无效值),即 不调整。有效值为>0 |
diffImgSmoothEnable | int | 开启后减少锐化带来的边缘artifacts,但锐化强度会比关闭时弱一些, 默认-1(无效值),即保持内部设置,目前设置为开启。 有效值为0或1,0--关闭,1--开启 |
onlineLicense | boolean | 授权类型 |
返回值
成功返回BEF_RESULT_SUC,否则返回对应的错误码
备注
这里只建议业务方调整两个参数:amount和over_ratio.
public int setProperty(
int sceneMode,
int powerLevel,
int frameWidth,
int frameHeight,
float amount,
float overRatio,
float edgeWeightGamma,
int diffImgSmoothEnable)
java
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
sceneMode | int | 场景模式 |
powerLevel | int | 传入频率设置等级,默认为auto等级(default是指随系统调节,low是使用低频率,normal是使用中频率,high是使用高频率,auto是sdk内部根据机型自动调节 |
frameHeight | int | 视频高度 |
frameWidth | int | 视频宽度 |
amount | float | 锐化强度增益,默认-1(无效值),即不调整。有效值为>0:当设置>1时,会增大锐化强度,设置<1时,减弱锐化强度。 |
overRatio | float | 黑白边的容忍度增益,默认-1(无效值),即不调整 |
edgeWeightGamma | float | 对中低频边缘的锐化强度进行调整, 默认-1(无效值),即 不调整。有效值为>0 |
diffImgSmoothEnable | int | 开启后减少锐化带来的边缘artifacts,但锐化强度会比关闭时弱一些, 默认-1(无效值),即保持内部设置,目前设置为开启。 有效值为0或1,0--关闭,1--开启 |
public int process(
int srcTextureId,
Integer destTextureId)
java
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
srcTextureId | int | 输入纹理号 |
srcTextureId | Integer | 输出纹理号 |
public void release()
java
答:建议首先查看以下tag输出Error类型的日志:
bef_effect_ai 和SMASH_E_LOG 以及 EffectSDK
错误码请参考错误码表