From 06d9122600054934d4793f8a55fe10289f410743 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期五, 15 十一月 2019 10:07:46 +0800
Subject: [PATCH] add comment
---
csrc/buz/plate/detector.cpp | 131 +++++++++++++++++++++++++++++++------------
1 files changed, 94 insertions(+), 37 deletions(-)
diff --git a/csrc/buz/plate/detector.cpp b/csrc/buz/plate/detector.cpp
index 81b2874..48cb2a5 100644
--- a/csrc/buz/plate/detector.cpp
+++ b/csrc/buz/plate/detector.cpp
@@ -12,38 +12,12 @@
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);
@@ -51,15 +25,98 @@
// 鍒濆鍖� 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 = params->nFastMemorySize * 1024;
+ int pMemSize = params->nMemorySize * 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);
+ return;
+ }
+ if (params->bOnlyTwoRowYellow == 1) {
+ TH_SetEnabledPlateFormat(PARAM_ONLY_TWOROWYELLOW_ON, &config);
+ return;
+ }
+ 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) {
@@ -78,7 +135,7 @@
rcDetect.top = 0;
rcDetect.right = img->width;
rcDetect.bottom = img->height;
- rcDetect.left = 0;
+ rcDetect.left = 0;
int ret = TH_RecogImage((BYTE*)(img->data), img->width, img->height, result, &nResultNum, &rcDetect, &config);
// printf("TH_RecogImage ret = %d\n", ret);
--
Gitblit v1.8.0