| | |
| | | static unsigned char *fmem; |
| | | static unsigned char *pmem; |
| | | |
| | | int init_plate_id_detector(const int width, const int height, char *soPath) { |
| | | int fMemSize = 0x8000; |
| | | int pMemSize = 200 * 1024 * 1024; |
| | | void init_plate_id_config(const cPlateIDCfg *params); |
| | | void set_enable_plate_format(const cPlateIDCfg *params); |
| | | |
| | | fmem = (unsigned char*)malloc(fMemSize * sizeof(unsigned char)); |
| | | pmem = (unsigned char*)malloc(pMemSize * sizeof(unsigned char)); |
| | | |
| | | config.nMinPlateWidth = 60; |
| | | config.nMaxPlateWidth = 400; |
| | | config.nMaxImageWidth = width; |
| | | config.nMaxImageHeight = height; |
| | | |
| | | config.bVertCompress = 0; |
| | | config.bIsFieldImage = 0; |
| | | config.bOutputSingleFrame = 1; |
| | | |
| | | config.pFastMemory = fmem; |
| | | config.nFastMemorySize = fMemSize; |
| | | config.pMemory = pmem; |
| | | config.nMemorySize= pMemSize; |
| | | |
| | | config.bUTF8 = 1; |
| | | |
| | | // 动态模式 |
| | | config.bMovingImage = 1; |
| | | config.nImageFormat = ImageFormatBGR; |
| | | |
| | | // 静态模式 |
| | | // config.bMovingImage = 0; |
| | | |
| | | // 识别车型 |
| | | config.bCarModel = 1; |
| | | int init_plate_id_detector(const cPlateIDCfg *params, char *soPath) { |
| | | // 初始化配置参数 |
| | | init_plate_id_config(params); |
| | | |
| | | // 设置Licence Manager运行路径 |
| | | int ret = TH_SetSoPath(soPath); |
| | |
| | | // 初始化 sdk |
| | | ret = TH_InitPlateIDSDK(&config); |
| | | |
| | | // 开启新能源车牌识别 |
| | | ret = TH_SetEnabledPlateFormat(PARAM_NEWENERGY_ON, &config); |
| | | |
| | | ret = TH_SetImageFormat(ImageFormatBGR, false, false, &config); |
| | | // 设置车牌类型识别 |
| | | set_enable_plate_format(params); |
| | | |
| | | // 设置识别阈值 |
| | | TH_SetRecogThreshold(5, 2, &config); |
| | | TH_SetRecogThreshold(params->bLocateTh, params->bOCRTh, &config); |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | void init_plate_id_config(const cPlateIDCfg *params) { |
| | | int fMemSize = 0x8000; |
| | | int pMemSize = 200 * 1024 * 1024; |
| | | |
| | | fmem = (unsigned char*)malloc(fMemSize * sizeof(unsigned char)); |
| | | pmem = (unsigned char*)malloc(pMemSize * sizeof(unsigned char)); |
| | | |
| | | // 默认参数 |
| | | config.nMinPlateWidth = 60; |
| | | config.nMaxPlateWidth = 400; |
| | | config.bVertCompress = 0; |
| | | config.nImageFormat = ImageFormatBGR; |
| | | config.bOutputSingleFrame = 1; |
| | | config.bUTF8 = 1; |
| | | |
| | | config.pFastMemory = fmem; |
| | | config.nFastMemorySize = fMemSize; |
| | | config.pMemory = pmem; |
| | | config.nMemorySize= pMemSize; |
| | | |
| | | if (params->nMinPlateWidth > 60 && params->nMinPlateWidth < 400) { |
| | | config.nMinPlateWidth = params->nMinPlateWidth; |
| | | } |
| | | if (params->nMaxPlateWidth > 60 && params->nMaxPlateWidth < 400) { |
| | | config.nMaxPlateWidth = params->nMaxPlateWidth; |
| | | } |
| | | |
| | | config.nMaxImageWidth = params->nMaxImageWidth; |
| | | config.nMaxImageHeight = params->nMaxImageHeight; |
| | | config.bIsFieldImage = params->bIsFieldImage; |
| | | config.bMovingImage = params->bMovingImage; |
| | | config.nOrderOpt = params->nOrderOpt; |
| | | config.bLeanCorrection = params->bLeanCorrection; |
| | | config.nImproveSpeed = params->nImproveSpeed; |
| | | config.bCarLogo = params->bCarLogo; |
| | | config.bLotDetect = params->bLotDetect; |
| | | config.bShadow = params->bShadow; |
| | | config.bShieldRailing = params->bShieldRailing; |
| | | config.bCarModel = params->bCarModel; |
| | | } |
| | | |
| | | void set_enable_plate_format(const cPlateIDCfg *params) { |
| | | if (params->bOnlyLocation == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_ONLY_LOCATION_ON, &config); |
| | | } |
| | | if (params->bOnlyTwoRowYellow == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_ONLY_TWOROWYELLOW_ON, &config); |
| | | } |
| | | if (params->bIndividual == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_INDIVIDUAL_ON, &config); |
| | | } |
| | | if (params->bTwoRowYellow == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_TWOROWYELLOW_ON, &config); |
| | | } |
| | | if (params->bArmPolice == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_ARMPOLICE_ON, &config); |
| | | } |
| | | if (params->bArmPolice2 == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_ARMPOLICE2_ON, &config); |
| | | } |
| | | if (params->bTwoRowArmy == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_TWOROWARMY_ON, &config); |
| | | } |
| | | if (params->bTractor == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_TRACTOR_ON, &config); |
| | | } |
| | | if (params->bEmbassy == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_EMBASSY_ON, &config); |
| | | } |
| | | if (params->bChangNei == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_CHANGNEI_ON, &config); |
| | | } |
| | | if (params->bMinHang == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_MINHANG_ON, &config); |
| | | } |
| | | if (params->bConsulate == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_CONSULATE_ON, &config); |
| | | } |
| | | if (params->bNewEnergy == 1) { |
| | | TH_SetEnabledPlateFormat(PARAM_NEWENERGY_ON, &config); |
| | | } |
| | | } |
| | | |
| | | cPlateIDResult* plate_id_detect(int *plateIDCount, const cIMAGE *img) { |
| | | if (!img) { |
| | | return NULL; |