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

车辆检测

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

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

简介

车辆检测SDK提供从图像中实时提取车辆、车牌信息的能力。

技术规格
支持平台Android、iOS、Windows、Mac
支持输入格式RGBA8888、BGRA8888、BGR888、RGB888、NV21、NV12、YUV420P
支持最小输入尺寸短边128
内存占用<3M (测试设备OppoR11)
检测速度<7ms(测试设备iPhone7)
C接口说明

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

1.创建车辆检测句柄

BEF_SDK_API
bef_effect_result_t
bef_effect_ai_car_detect_create_handle(bef_ai_car_handle* handle);

参数说明

参数名参数类型参数说明
handlebef_ai_car_handle创建的车辆检测句柄

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

2.从文件初始化模型参数

BEF_SDK_API
bef_effect_result_t
bef_effect_ai_car_detect_init_model(bef_ai_car_handle handle,
                                           bef_ai_car_model_type modelType,
                                           const char* modelPath);

参数说明

参数名参数类型参数说明
handlebef_ai_car_handle车辆检测句柄
modelTypebef_ai_car_model_type车辆检测模型类型
modelPathconst char*模型文件的路径

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

3.设置SDK参数

BEF_SDK_API
bef_effect_result_t
bef_effect_ai_car_detect_set_paramf(bef_ai_car_handle handle,
                                           bef_ai_car_param_type type,
                                           float value);

参数说明

参数名参数类型参数说明
handlebef_ai_car_handle车辆检测句柄
use_trackingbef_ai_car_param_type算法内部参数,目前传入 true 即可
use_blurfloat算法内部参数,目前传入 true 即可

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

4.进行车辆检测

BEF_SDK_API
bef_effect_result_t
bef_effect_ai_car_detect_detect(bef_ai_car_handle 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,
                                       bef_ai_car_ret* car_info);

参数说明

参数名参数类型参数说明
handlebef_ai_car_handle车辆检测句柄
imageconst unsigned char*为传入图像的大小,图像大小任意
pixel_formatbef_ai_pixel_format传入图像的类型
image_widthint传入图像的宽
image_heightint传入图像的高
image_strideint传入图像的步长
orientationbef_ai_rotate_type传入图像旋转角
bef_ai_car_retbef_ai_car_ret检测结果

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

5.释放句柄

BEF_SDK_API
bef_effect_result_t bef_effect_ai_car_detect_destroy(bef_ai_car_handle handle);

参数说明

参数名参数类型参数说明
handlebef_ai_car_handle车辆检测句柄

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

6.车辆检测授权

BEF_SDK_API
bef_effect_result_t bef_effect_ai_car_detect_check_license(bef_ai_car_handle handle, const char* licensePath);

参数说明

参数名参数类型参数说明
handlebef_ai_car_handle车辆检测句柄
licensePathconst char *授权文件字符串

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

Java 接口说明

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

1.初始化车辆检测句柄

public int createHandle(String licensePath);

参数说明

参数名参数类型参数说明
licensePathconst char *授权文件绝对路径

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

2.设置SDK参数

public int setParam(BytedEffectConstants.CarParamType paramType, float paramValue)

参数说明

参数名参数类型参数说明
paramTypeBytedEffectConstants.CarParamType是否跟踪 传入true
paramValuefloat是否模糊 传入true

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

3.设置模型

public int setModel(BytedEffectConstants.CarModelType modelType, 
                    String modelPath)

参数说明

参数名参数类型参数说明
modelTypeBytedEffectConstants.CarModelType
modelPathString

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

4.执行车辆检测

public BefCarDetectInfo detect(ByteBuffer buffer,
                               BytedEffectConstants.PixlFormat pixel_format,
                               int image_width, 
                               int image_height,
                               int image_stride, 
                               BytedEffectConstants.Rotation orientation)

参数说明

参数名参数类型参数说明
bufferByteBuffer输入图像数据
pixel_formatBytedEffectConstants.PixlFormat输入数据格式
image_widthint输入图像宽度
image_heightint输入图像高度
image_strideint输入图像步长
orientationBytedEffectConstants.Rotation输入图像旋转角

返回值
成功返回 类BefCarDetectInfo-车辆检测结果

5.释放车辆检测句柄

public void release()

FAQ

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

答:建议首先查看以下tag输出Error类型的日志:

bef_effect_ai 和SMASH_E_LOG 以及 EffectSDK

错误码

错误码请参考错误码表