#include "detector.h" #include #include #include "LPRecognition.h" #include "csdk_struct.h" namespace csdk_wrap { static void* pInstance; static LPR_RecParma RecParam; void init_plate_id_cloud_sdk_config(const cPlateIDCloudSDKCfg *params); int init_plate_id_cloud_sdk_detector(const cPlateIDCloudSDKCfg *params, char *keyPath, char *modelPath) { // 读取授权 int iInitFlag = LPR_ThreadInit(keyPath); if(iInitFlag != LPR_OK) { return iInitFlag; } // 初始化配置参数 init_plate_id_cloud_sdk_config(params); // 设置Licence Manager运行路径 pInstance = LPR_Cloud_Init(RecParam, modelPath); return pInstance == NULL ? 1 : 0; } void init_plate_id_cloud_sdk_config(const cPlateIDCloudSDKCfg *params) { RecParam.eImageType = E_LPR_BGR; RecParam.iHorCorrect = 1; RecParam.iVerCorrect = 1; RecParam.iPlateBornThr = 0; RecParam.iPlateNumThr = 0; RecParam.iPlateDeadThr = 0; RecParam.iResultNum = 4; RecParam.iRecMode = params->iRecMode; RecParam.iImageMode = params->iImageMode; RecParam.iMinPlateWidth = params->iMinPlateWidth; RecParam.iMaxPlateWidth = params->iMaxPlateWidth; RecParam.iImageHeight = params->iImageHeight; RecParam.iImageWidth = params->iImageWidth; RecParam.iMinHorAngle = params->iMinHorAngle; RecParam.iMaxHorAngle = params->iMaxHorAngle; RecParam.iMinVerAngle = params->iMinVerAngle; RecParam.iMaxVerAngle = params->iMaxVerAngle; RecParam.fExpLeftRightR = params->fExpLeftRightR; RecParam.fExpTopR = params->fExpTopR; RecParam.fExpBottomR = params->fExpBottomR; } cPlateIDCloudSDKResult* plate_id_cloud_sdk_detect(int *plateIDCount, const cIMAGE *img, const cRECT *rect) { if (!img) { return NULL; } cPlateIDCloudSDKResult *ppos = NULL; ::LPR_Result pLprResult[20]; memset(&pLprResult, 0, sizeof(pLprResult)); // 设置识别区域 ::LPR_Rect rcDetect = {rect->left, rect->top, rect->right, rect->bottom}; int iVehicleNum = LPR_Cloud_RecImage((BYTE*)(img->data), img->width, img->height, pLprResult, &rcDetect, pInstance); if (iVehicleNum > 0){ ppos = (cPlateIDCloudSDKResult*)malloc(iVehicleNum * sizeof(cPlateIDCloudSDKResult)); *plateIDCount = iVehicleNum; memcpy(ppos, pLprResult, sizeof(LPR_Result) * iVehicleNum); } return ppos; } void uninit_plate_id_cloud_sdk_detector() { LPR_Cloud_Uninit(pInstance); } } // csdk_wrap