/************************************************************************* * Version: vehicle_plate_detection_and_recognition_v0.2.3.20191120 * CopyRight:中科视语(北京)科技有限公司 * UpdateDate:20191120 * Content:车牌检测识别*************************************************************************/ #ifndef VEHICLEPLATEDR_H_ #define VEHICLEPLATEDR_H_ #if _MSC_VER #ifdef VEHICLEPLATEDR_EXPORTS #define VEHICLEPLATEDR_API __declspec(dllexport) #else #define VEHICLEPLATEDR_API __declspec(dllimport) #endif #else #define VEHICLEPLATEDR_API __attribute__ ((visibility ("default"))) #endif #include "sy_common.h" #ifdef __cplusplus extern "C" { #endif #define PLATENUM 8 //车牌号码位数 #define MAXPLATECOUNT 20 //支持最多20个车牌的检测 //车牌类型 #define SINGLETYPE_BLUE 0 //单排蓝色 #define SINGLETYPE_YELLOW 1 //单排黄色 #define SINGLETYPE_WHITE 2 //单排白色 #define SINGLETYPE_BLACK 3 //单排黑色 #define DOUBLETYPE_YELLOW 4 //双排黄色 #define DOUBLETYPE_WHITE 5 //双排白色 #define NEWENERGYTYPE_YELLOWGREEN 6 //新能源黄绿色 #define NEWENERGYTYPE_WHITEGRA 7 //新能源白绿色 //车牌号码 #ifndef VPLATENUM_RESULT_ #define VPLATENUM_RESULT_ typedef struct vplate_num { char character[4]; float maxprob; int index; }vplate_num; #endif #ifndef VP_RESULT_ #define VP_RESULT_ typedef struct vplate_result { sy_rect rect; float detect_score; vplate_num recg[PLATENUM]; float num_score; int type; //车牌类型。只做车牌检测,车牌类型为:0-单层车牌,1-双层车牌;做车牌检测识别,0-单排蓝色 1-单排黄色 2-单排白色 3-单排黑色 4-双排黄色 5-双排白色 6-新能源黄绿色 7-新能源白绿色 int state; //车牌状态:0-无车牌,1-车牌,2-遮挡车牌 float state_score;//车牌状态置信度 sy_point rr_point[4];//斜框 }vplate_result; #endif #ifndef VPS_RESULT_ #define VPS_RESULT_ typedef struct vplates_result { vplate_result vehicle_plate_infos[MAXPLATECOUNT]; int count; }vplates_result; #endif #ifndef __VPD_PARAM__ #define __VPD_PARAM__ typedef struct vpd_param { float thresld; //检测阈值 建议阈值 0.3 int devId; //指定显卡id char* modelNames; // int mode; //运行模式(DEVICE_GPU / DEVICE_CPU) // int engine; //指定运行引擎 (ENGINE_MCAFFE2 / ENGINE_TENSORRT) // int max_batch; //指定trt框架最大batch数 // char* serialize_file; // vpd_param() : thresld(0.3), gpuid(0), mode(DEVICE_GPU), engine(ENGINE_TENSORRT),max_batch(10),serialize_file("VPDR") {}; }vpd_param; #endif #ifndef __VPR_PARAM__ #define __VPR_PARAM__ typedef struct vpr_param { // int gpuid; // int mode; char* cls_modelNames; //号牌分类 char* reg_modelNames; //号牌识别 // int engine; //指定运行引擎 (ENGINE_MCAFFE2 / ENGINE_TENSORRT) // int max_batch; //指定trt框架最大batch数 // char* serialize_file; // vpr_param() :gpuid(0), mode(DEVICE_GPU), engine(ENGINE_TENSORRT),max_batch(10),serialize_file("VPRecg") {}; }vpr_param; #endif /************************************************************************* * FUNCTION: vpdr_init * PURPOSE: 初始化句柄 * PARAM: [in] handle - 句柄 [in] params - 参数 * RETURN: 成功或者错误代码 *************************************************************************/ VEHICLEPLATEDR_API int vpdr_init(void ** handle, vpd_param dparam, vpr_param rparam); /************************************************************************* * * FUNCTION: vpd_process * * PURPOSE: 车牌检测 * PARAM: * [in] handle - 检测句柄 * [in] img_data - 图像数据 * [in] result - 结果 内存在外部申请 * RETURN: 成功 或者 错误代码 * * NOTES: * *************************************************************************/ VEHICLEPLATEDR_API int vpd_process(void * handle, sy_img img_data, vplates_result * result); VEHICLEPLATEDR_API int vpd_batch(void *handle, sy_img* img_data, int batch_size, vplates_result *result); /************************************************************************* * FUNCTION: vpr_process * PURPOSE: 车牌识别(识别接口只支持正的单层车牌或矫正裁剪成单层的双层车牌) * PARAM: [in] handle - 检测句柄 [in] img_data - 图像数据 [in] result - 结果 内存在外部申请 * RETURN: 成功 或者 错误代码 * NOTES: *************************************************************************/ VEHICLEPLATEDR_API int vpr_process(void * handle, sy_img img_data, vplate_result * result); VEHICLEPLATEDR_API int vpr_batch(void *handle, sy_img* img_data, int batch_size, vplate_result * result); /************************************************************************* * FUNCTION: vpdr_process * PURPOSE: 车牌检测识别 * PARAM: [in] handle - 检测句柄 [in] img_data - 图像数据 [in] result - 结果 内存在外部申请 * RETURN: 成功 或者 错误代码 * NOTES: *************************************************************************/ VEHICLEPLATEDR_API int vpdr_process(void *handle, sy_img img_data, vplates_result * result); VEHICLEPLATEDR_API int vpdr_batch(void *handle, sy_img* img_data, int batch_size, vplates_result *result); /************************************************************************* * FUNCTION: vpdr_release * PURPOSE: 释放 * PARAM: [in] handle - handle * RETURN: NULL * NOTES: *************************************************************************/ VEHICLEPLATEDR_API void vpdr_release(void ** handle); /************************************************************************* * FUNCTION: vpdr_get_version * PURPOSE: * PARAM: NULL * RETURN: 版本号 * NOTES: *************************************************************************/ VEHICLEPLATEDR_API const char * vpdr_get_version(); #ifdef __cplusplus }; #endif #endif