From a8ff93a0cf274795f0e9c3d66093f1c4c6ccf972 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期二, 19 十一月 2019 15:57:02 +0800
Subject: [PATCH] feat: add cloud plate sdk

---
 csrc/buz/plate/cloud/detector.h             |   17 +
 csrc/buz/plate/eparking/detector.h          |    5 
 sdk/plate/eparking/include/TH_ErrorDef.h    |    0 
 csdk.h                                      |    7 
 sdk/plate/cloud/lib/libLPRecognition.so     |    0 
 sdk/plate/cloud/include/LPRecognition.h     |  167 ++++++++++++++++++
 c2go.go                                     |   14 +
 sdk/plate/cloud/lib/libgfortran.so.3        |    0 
 sdk/plate/cloud/lib/plate_det.model         |    0 
 go2c.go                                     |   48 +++++
 csrc/buz/plate/cloud/detector.cpp           |   89 +++++++++
 csrc/all.hpp                                |    4 
 csrc/buz/plate/eparking/detector.cpp        |    8 
 csdk.cpp                                    |   18 +
 sdk/plate/eparking/lib/libthplateid.so      |    0 
 gosdk.go                                    |   73 ++++++-
 sdk/plate/eparking/lib/libLicenceManager.so |    0 
 sdk/plate/cloud/lib/libLPRecognition.a      |    0 
 sdk/plate/cloud/lib/libopenblas.so.0        |    0 
 sdk/plate/eparking/include/TH_PlateID.h     |    0 
 csdk_struct.h                               |   51 +++++
 21 files changed, 476 insertions(+), 25 deletions(-)

diff --git a/c2go.go b/c2go.go
index 0f25bea..0c346cc 100644
--- a/c2go.go
+++ b/c2go.go
@@ -76,3 +76,17 @@
 	}
 	return
 }
+
+// CPlateIDCloudPosArrayToGoArray convert CPlateIDCloudResult array to go
+func CPlateIDCloudPosArrayToGoArray(cArray unsafe.Pointer, count int) (goArray []CPlateIDCloudResult) {
+	p := uintptr(cArray)
+
+	for i := 0; i < count; i++ {
+		j := *(*CPlateIDCloudResult)(unsafe.Pointer(p))
+
+		goArray = append(goArray, j)
+
+		p += unsafe.Sizeof(j)
+	}
+	return
+}
diff --git a/csdk.cpp b/csdk.cpp
index 052fd84..02b15d6 100644
--- a/csdk.cpp
+++ b/csdk.cpp
@@ -107,11 +107,25 @@
     return init_plate_id_detector(config, soPath);
 }
 
-cPlateIDResult* c_api_plate_id_detect(int *plateIDCount, uchar *data, const int w, const int h) {
+cPlateIDResult* c_api_plate_id_detect(int *plateIDCount, uchar *data, const int w, const int h, const cRECT *rcDetect) {
     const cIMAGE img{data, w, h, 3};
-    return plate_id_detect(plateIDCount, &img);
+    return plate_id_detect(plateIDCount, &img, rcDetect);
 }
 
 int c_api_plate_id_free() {
     return uninit_plate_id_detector();
+}
+
+// plateid cloud sdk api
+int c_api_plate_id_cloud_init(const cPlateIDCloudSDKCfg *config, char *soPath, char *modelPath) {
+    return init_plate_id_cloud_sdk_detector(config, soPath, modelPath);
+}
+
+cPlateIDCloudSDKResult* c_api_plate_id_cloud_detect(int *plateIDCount, uchar *data, const int w, const int h, const cRECT *rcDetect) {
+    const cIMAGE img{data, w, h, 3};
+    return plate_id_cloud_sdk_detect(plateIDCount, &img, rcDetect);
+}
+
+void c_api_plate_id_cloud_free() {
+    uninit_plate_id_cloud_sdk_detector();
 }
\ No newline at end of file
diff --git a/csdk.h b/csdk.h
index e4f9961..666994b 100644
--- a/csdk.h
+++ b/csdk.h
@@ -42,9 +42,14 @@
 
 // plateid api
 int c_api_plate_id_init(const cPlateIDCfg *config, char *soPath);
-cPlateIDResult* c_api_plate_id_detect(int *plateIDCount, uchar*data, const int w, const int h);
+cPlateIDResult* c_api_plate_id_detect(int *plateIDCount, uchar*data, const int w, const int h, const cRECT *rcDetect);
 int c_api_plate_id_free();
 
+// plateid cloud sdk
+int c_api_plate_id_cloud_init(const cPlateIDCloudSDKCfg *config, char *soPath, char *modelPath);
+cPlateIDCloudSDKResult* c_api_plate_id_cloud_detect(int *plateIDCount, uchar *data, const int w, const int h, const cRECT *rcDetect);
+void c_api_plate_id_cloud_free();
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/csdk_struct.h b/csdk_struct.h
index a6b2374..e5a1465 100644
--- a/csdk_struct.h
+++ b/csdk_struct.h
@@ -105,8 +105,7 @@
     unsigned char bOnlyLocation;    // 鍙畾浣嶈溅鐗屽紑鍚�
 }cPlateIDCfg;
 
-typedef struct _cPlateIDResult 
-{
+typedef struct _cPlateIDResult {
 	char license[16];	// 杞︾墝瀛楃涓�
 	char color[8];		// 杞︾墝棰滆壊
 
@@ -132,4 +131,52 @@
 	unsigned short nCarModelConfidence;	// 杞﹀瀷鍙俊搴�	
 }cPlateIDResult;
 
+typedef struct _cPlateIDCloudSDKCfg {
+	int iImageMode;         //0锛氫负甯фā寮� 1锛氫负鍦烘ā寮�
+	int iRecMode;           //璇嗗埆妯″紡锛�0锛氬崟寮犲浘鐗囪瘑鍒紝1:瑙嗛妫�娴�+璇嗗埆锛�2锛氳棰戝甯ц瀺鍚堣瘑鍒�(娉細1妯″紡姣�2妯″紡蹇紝浣嗚瘑鍒巼鍜屾崟鑾风巼姣�2浣�)
+	                          
+	int iMinPlateWidth;     //璇嗗埆鏈�灏忚溅鐗屽搴�
+	int iMaxPlateWidth;     //璇嗗埆鏈�澶ц溅鐗屽搴�
+	
+	int iImageWidth;        //鍥剧墖瀹藉害 
+	int iImageHeight;       //鍥剧墖楂樺害
+
+	int iMinHorAngle; 
+	int iMaxHorAngle;       //姘村钩鐭瑙掑害鑼冨洿锛屾敮鎸佹渶澶ц搴︿负[-30掳锛�30掳]
+	int iMinVerAngle;
+	int iMaxVerAngle;       //鍨傜洿鐭瑙掑害鑼冨洿锛屾敮鎸佹渶澶ц搴︿负[-30掳锛�30掳]
+
+	//姝や簺椤归拡瀵硅溅鍨嬭瘑鍒湁鐢紝鍏朵綑鏃犵敤
+	float fExpLeftRightR;   //杞﹁劯宸﹀彸鎵╁厖(杞︾墝鐨勫搴�)鍊嶆暟 鍙傝�冨�间负1.6
+	float fExpTopR;         //杞﹁劯涓婇儴鎵╁厖(杞︾墝鐨勯珮搴�)鍊嶆暟 鍙傝�冨�间负6.0
+	float fExpBottomR;      //杞﹁劯涓嬮儴鎵╁厖(杞︾墝鐨勯珮搴�)鍊嶆暟 鍙傝�冨�间负1.5
+}cPlateIDCloudSDKCfg;
+
+typedef struct _cPlateIDCloudSDKResult {
+	char number[20];     //璇嗗埆缁撴灉
+	cRECT PlateRect;    //杞︾墝浣嶇疆
+	int x[4];
+	int y[4];
+	int iConfidence;    //杞︾墝缃俊搴�
+	int ePlateType;     //杞︾墝绫诲瀷
+	int iMoveDir;       //杞﹁締杩愬姩鏂瑰悜 0锛氭湞杩戣繍鍔紝1锛氭湞杩滆繍鍔紝-1锛氭湭鐭�
+	int eVColor1;       //杞﹁韩涓婚鑹�
+	int eVColor2;       //杞﹁韩娆¢鑹�
+	int eVehicleBright; //杞﹁締娣辨祬鑹�
+	unsigned char *pResultBits; //瑙嗛璇嗗埆妯″紡涓姄鎷嶇殑鍥剧墖,瑙嗛妯″紡璇嗗埆涓嬫湁鏁堬紝闇�瑕佸紑杈�
+	
+	int iFramNo;        //瑙嗛妯″紡涓嬪抚鍙�
+	int sTime[7];       //瑙嗛璇嗗埆妯″紡涓姄鎷嶆寮犲浘鐨勬椂闂�
+	
+	//閽堝杞﹁劯璇嗗埆搴旂敤姝ら」锛屽叾浣欐棤鐢�
+	unsigned char  *pVehicleFaceImage; //瀵瑰簲鐨勮溅鑴哥殑鍥剧墖,闇�瑕佹彁鍓嶅紑杈熷唴瀛橈紝寮�杈熶釜鏈�澶у唴瀛樺氨鍙互锛屽楂樺彲浠ラ兘涓�1000
+	int iVehicleFaceWidth;             //杞﹁劯瀹藉害
+	int iVehicleFaceHeight;            //杞﹁劯楂樺害
+	int iGrayFaceFlag;                 //杞﹁劯鏄惁涓虹伆搴﹀浘
+
+	cRECT charLocation[20];     //杞︾墝瀛楃鐨勪綅缃�(鍩轰簬澶у浘)
+	int charConfidence[20];     //瀛楃璇嗗埆缃俊搴�
+	int iCharNum;               //杞︾墝瀛楃鏁扮洰
+}cPlateIDCloudSDKResult;
+
 #endif
\ No newline at end of file
diff --git a/csrc/all.hpp b/csrc/all.hpp
index 96a7cbc..1414dd6 100644
--- a/csrc/all.hpp
+++ b/csrc/all.hpp
@@ -8,5 +8,7 @@
 
 #include "buz/yolo/detector.cpp"
 
-#include "buz/plate/detector.cpp"
+#include "buz/plate/eparking/detector.cpp"
+#include "buz/plate/cloud/detector.cpp"
+
 #endif
\ No newline at end of file
diff --git a/csrc/buz/plate/cloud/detector.cpp b/csrc/buz/plate/cloud/detector.cpp
new file mode 100644
index 0000000..2bf5134
--- /dev/null
+++ b/csrc/buz/plate/cloud/detector.cpp
@@ -0,0 +1,89 @@
+#include "detector.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#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
diff --git a/csrc/buz/plate/cloud/detector.h b/csrc/buz/plate/cloud/detector.h
new file mode 100644
index 0000000..a101ce2
--- /dev/null
+++ b/csrc/buz/plate/cloud/detector.h
@@ -0,0 +1,17 @@
+#ifndef _c_wrapper_plate_detector_hpp_
+#define _c_wrapper_plate_detector_hpp_
+
+#include "../../base.hpp"
+
+struct _cPlateIDCloudSDKCfg;
+struct _cPlateIDCloudSDKResult;
+struct _cIMAGE;
+struct _cRECT;
+
+namespace csdk_wrap{
+    int init_plate_id_cloud_sdk_detector(const cPlateIDCloudSDKCfg *params, char *keyPath, char *modelPath);
+    cPlateIDCloudSDKResult* plate_id_cloud_sdk_detect(int *plateIDCount, const cIMAGE *img, const cRECT *rect);
+    void uninit_plate_id_cloud_sdk_detector();
+}
+
+#endif
\ No newline at end of file
diff --git a/csrc/buz/plate/detector.cpp b/csrc/buz/plate/eparking/detector.cpp
similarity index 96%
rename from csrc/buz/plate/detector.cpp
rename to csrc/buz/plate/eparking/detector.cpp
index 710dff9..2ffbaaa 100644
--- a/csrc/buz/plate/detector.cpp
+++ b/csrc/buz/plate/eparking/detector.cpp
@@ -120,7 +120,7 @@
         }
     }
 
-    cPlateIDResult* plate_id_detect(int *plateIDCount, const cIMAGE *img) {
+    cPlateIDResult* plate_id_detect(int *plateIDCount, const cIMAGE *img, const cRECT *rect) {
         if (!img) {
             return NULL;
         }
@@ -132,11 +132,7 @@
         memset(&result[0], 0, sizeof(result));
 
         // 璁剧疆璇嗗埆鍖哄煙
-        ::TH_RECT rcDetect;
-        rcDetect.top = 0;
-        rcDetect.right = img->width;
-        rcDetect.bottom = img->height;
-        rcDetect.left = 0;
+        ::TH_RECT rcDetect = {rect->left, rect->top, rect->right, rect->bottom};
 
         int ret = TH_RecogImage((BYTE*)(img->data), img->width, img->height, result, &nResultNum, &rcDetect, &config);
         // printf("TH_RecogImage ret = %d\n", ret);
diff --git a/csrc/buz/plate/detector.h b/csrc/buz/plate/eparking/detector.h
similarity index 82%
rename from csrc/buz/plate/detector.h
rename to csrc/buz/plate/eparking/detector.h
index 2889503..67937a7 100644
--- a/csrc/buz/plate/detector.h
+++ b/csrc/buz/plate/eparking/detector.h
@@ -1,15 +1,16 @@
 #ifndef _c_wrapper_plate_detector_hpp_
 #define _c_wrapper_plate_detector_hpp_
 
-#include "../base.hpp"
+#include "../../base.hpp"
 
 struct _cPlateIDCfg;
 struct _cPlateIDResult;
 struct _cIMAGE;
+struct _cRECT;
 
 namespace csdk_wrap{
     int init_plate_id_detector(const cPlateIDCfg *params, char *soPath);
-    cPlateIDResult* plate_id_detect(int *plateIDCount, const cIMAGE *img);
+    cPlateIDResult* plate_id_detect(int *plateIDCount, const cIMAGE *img, const cRECT *rect);
     int uninit_plate_id_detector();
 }
 
diff --git a/go2c.go b/go2c.go
index 97909d6..898623d 100644
--- a/go2c.go
+++ b/go2c.go
@@ -126,3 +126,51 @@
 	NCarModel           [2]uint8  // 杞﹁締绫诲瀷
 	NCarModelConfidence [2]uint8  // 杞﹀瀷鍙俊搴�
 }
+
+type CPlateIDCloudCfg struct {
+	NImageMode int32 //0锛氫负甯фā寮� 1锛氫负鍦烘ā寮�
+	NRecMode   int32 //璇嗗埆妯″紡锛�0锛氬崟寮犲浘鐗囪瘑鍒紝1:瑙嗛妫�娴�+璇嗗埆锛�2锛氳棰戝甯ц瀺鍚堣瘑鍒�(娉細1妯″紡姣�2妯″紡蹇紝浣嗚瘑鍒巼鍜屾崟鑾风巼姣�2浣�)
+
+	NMinPlateWidth int32 //璇嗗埆鏈�灏忚溅鐗屽搴�
+	NMaxPlateWidth int32 //璇嗗埆鏈�澶ц溅鐗屽搴�
+
+	NImageWidth  int32 //鍥剧墖瀹藉害
+	NImageHeight int32 //鍥剧墖楂樺害
+
+	NMinHorAngle int32
+	NMaxHorAngle int32 //姘村钩鐭瑙掑害鑼冨洿锛屾敮鎸佹渶澶ц搴︿负[-30掳锛�30掳]
+	NMinVerAngle int32
+	NMaxVerAngle int32 //鍨傜洿鐭瑙掑害鑼冨洿锛屾敮鎸佹渶澶ц搴︿负[-30掳锛�30掳]
+
+	//姝や簺椤归拡瀵硅溅鍨嬭瘑鍒湁鐢紝鍏朵綑鏃犵敤
+	FExpLeftRightR float32 //杞﹁劯宸﹀彸鎵╁厖(杞︾墝鐨勫搴�)鍊嶆暟 鍙傝�冨�间负1.6
+	FExpTopR       float32 //杞﹁劯涓婇儴鎵╁厖(杞︾墝鐨勯珮搴�)鍊嶆暟 鍙傝�冨�间负6.0
+	FExpBottomR    float32 //杞﹁劯涓嬮儴鎵╁厖(杞︾墝鐨勯珮搴�)鍊嶆暟 鍙傝�冨�间负1.5
+}
+
+type CPlateIDCloudResult struct {
+	License     [20]uint8 //璇嗗埆缁撴灉
+	RcLocation  CRECT     //杞︾墝浣嶇疆
+	X           [4]int32
+	Y           [4]int32
+	NConfidence int32 //杞︾墝缃俊搴�
+	NType       int32 //杞︾墝绫诲瀷
+	NDirection  int32 //杞﹁締杩愬姩鏂瑰悜 0锛氭湞杩戣繍鍔紝1锛氭湞杩滆繍鍔紝-1锛氭湭鐭�
+	NCarColor   int32 //杞﹁韩涓婚鑹�
+	NCarColor1  int32 //杞﹁韩娆¢鑹�
+	NBright     int32 //杞﹁締娣辨祬鑹�
+	PResultBits int32 //瑙嗛璇嗗埆妯″紡涓姄鎷嶇殑鍥剧墖,瑙嗛妯″紡璇嗗埆涓嬫湁鏁堬紝闇�瑕佸紑杈�
+
+	FramNo int32    //瑙嗛妯″紡涓嬪抚鍙�
+	Time   [7]int32 //瑙嗛璇嗗埆妯″紡涓姄鎷嶆寮犲浘鐨勬椂闂�
+
+	//閽堝杞﹁劯璇嗗埆搴旂敤姝ら」锛屽叾浣欐棤鐢�
+	FaceImage    int32 //瀵瑰簲鐨勮溅鑴哥殑鍥剧墖,闇�瑕佹彁鍓嶅紑杈熷唴瀛橈紝寮�杈熶釜鏈�澶у唴瀛樺氨鍙互锛屽楂樺彲浠ラ兘涓�1000
+	FaceWidth    int32 //杞﹁劯瀹藉害
+	FaceHeight   int32 //杞﹁劯楂樺害
+	GrayFaceFlag int32 //杞﹁劯鏄惁涓虹伆搴﹀浘
+
+	CharLocation   [20]CRECT //杞︾墝瀛楃鐨勪綅缃�(鍩轰簬澶у浘)
+	CharConfidence [20]CRECT //瀛楃璇嗗埆缃俊搴�
+	CharNum        int32     //杞︾墝瀛楃鏁扮洰
+}
diff --git a/gosdk.go b/gosdk.go
index 5f2088e..13abe89 100644
--- a/gosdk.go
+++ b/gosdk.go
@@ -1,11 +1,14 @@
 package gosdk
 
 /*
-#cgo CFLAGS: -I. -I./sdk/face/include -I./sdk/darknet/include -I/usr/local/cuda/include -I./sdk/plate/include -w -g
-#cgo CXXFLAGS: -I. -I./sdk/face/include -I./sdk/darknet/include -I/usr/local/cuda/include -I./sdk/plate/include -w -g -std=c++11
-#cgo LDFLAGS: -L/usr/local/cuda/lib64 -L${SRCDIR}/sdk/face/lib/gpu -L${SRCDIR}/sdk/darknet/lib -L${SRCDIR}/sdk/plate/lib
-#cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/sdk/face/lib/gpu:${SRCDIR}/sdk/darknet/lib
-#cgo LDFLAGS: -ldarknet -lTHFaceImage -lTHFeature -lTHFaceProperty -lTHFaceTracking -lcudart -lcublas -lcurand -lrt -ldl -lpthread -lthplateid
+#cgo CFLAGS: -I. -I./sdk/face/include -I./sdk/darknet/include -I/usr/local/cuda/include -w -g
+#cgo CFLAGS:  -I./sdk/plate/eparking/include -I./sdk/plate/cloud/include
+#cgo CXXFLAGS: -I. -I./sdk/face/include -I./sdk/darknet/include -I/usr/local/cuda/include -w -g -std=c++11
+#cgo CXXFLAGS: -I./sdk/plate/eparking/include -I./sdk/plate/cloud/include
+#cgo LDFLAGS: -L/usr/local/cuda/lib64 -L${SRCDIR}/sdk/face/lib/gpu -L${SRCDIR}/sdk/darknet/lib
+#cgo LDFLAGS: -L${SRCDIR}/sdk/plate/eparking/lib -L${SRCDIR}/sdk/plate/cloud/lib
+#cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/sdk/face/lib/gpu:${SRCDIR}/sdk/darknet/lib:${SRCDIR}/sdk/plate/cloud/lib
+#cgo LDFLAGS: -ldarknet -lTHFaceImage -lTHFeature -lTHFaceProperty -lTHFaceTracking -lcudart -lcublas -lcurand -lrt -ldl -lpthread -lthplateid -lLPRecognition
 #include <stdlib.h>
 #include "csdk.h"
 */
@@ -420,7 +423,7 @@
 		MaxImageWidth: 4096,
 		MaxImageHeight: 2160,
 		IsFieldImage: 0,
-		MovingImage: 1,
+		MovingImage: 0,
 		OrderOpt: 0,
 		LeanCorrection: 1,
 		ImproveSpeed: 0,
@@ -439,9 +442,9 @@
 		TwoRowArmy: 1,
 		Tractor: 1,
 		Embassy: 1,
-		ChangNei: 1,
-		MinHang: 1,
-		Consulate: 1,
+		ChangNei: 0,
+		MinHang: 0,
+		Consulate: 10,
 		NewEnergy: 1,
 		OnlyTwoRowYellow: 0,
 		OnlyLocation: 0,
@@ -454,13 +457,13 @@
 }
 
 // PlateIDDetect plateid detect
-func PlateIDDetect(img SDKImage) []CPlateIDResult {
+func PlateIDDetect(img SDKImage, rcDetect *CRECT) []CPlateIDResult {
 	data := img.Data
 	w := img.Width
 	h := img.Height
 
 	var count C.int
-	cppos := C.c_api_plate_id_detect(&count, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h))
+	cppos := C.c_api_plate_id_detect(&count, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h), (*C.cRECT)(unsafe.Pointer(rcDetect)))
 	if cppos != nil {
 		defer C.free(unsafe.Pointer(cppos))
 		return CPlateIDPosArrayToGoArray(unsafe.Pointer(cppos), int(count))
@@ -470,4 +473,52 @@
 
 func FreePlateIdDetector() int{
 	return int(C.c_api_plate_id_free())
+}
+
+
+func DefaultPlateIDCloudSDKConfig() *CPlateIDCloudCfg{
+	return &CPlateIDCloudCfg{
+		NImageMode: 0,
+		NRecMode:   0,
+	
+		NMinPlateWidth: 60,
+		NMaxPlateWidth: 400,
+	
+		NImageWidth:  4096,
+		NImageHeight: 2160,
+	
+		NMinHorAngle: -15,
+		NMaxHorAngle: 15,
+		NMinVerAngle: -30,
+		NMaxVerAngle: 30,
+	
+		FExpLeftRightR: 1.6,
+		FExpTopR:       6.0,
+		FExpBottomR:    1.5,
+	}
+}
+
+// InitPlateIDCloudSDKDetector init plateid detector
+func InitPlateIDCloudSDKDetector(config *CPlateIDCloudCfg, keyPath, modelPath[]byte) int {
+	return int(C.c_api_plate_id_cloud_init((*C.cPlateIDCloudSDKCfg)(unsafe.Pointer(config)), (*C.char)(unsafe.Pointer(&keyPath[0])), (*C.char)(unsafe.Pointer(&modelPath[0]))))
+}
+
+// PlateIDCloudSDKDetect plateid detect
+func PlateIDCloudSDKDetect(img SDKImage, rcDetect *CRECT) []CPlateIDCloudResult {
+	data := img.Data
+	w := img.Width
+	h := img.Height
+
+	var count C.int
+	cppos := C.c_api_plate_id_cloud_detect(&count, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h), (*C.cRECT)(unsafe.Pointer(rcDetect)))
+	if cppos != nil {
+		defer C.free(unsafe.Pointer(cppos))
+		return CPlateIDCloudPosArrayToGoArray(unsafe.Pointer(cppos), int(count))
+	}
+	return nil
+}
+
+// FreePlateIDCloudSDKDetector free
+func FreePlateIDCloudSDKDetector() {
+	C.c_api_plate_id_free()
 }
\ No newline at end of file
diff --git a/sdk/plate/cloud/include/LPRecognition.h b/sdk/plate/cloud/include/LPRecognition.h
new file mode 100644
index 0000000..f7e1064
--- /dev/null
+++ b/sdk/plate/cloud/include/LPRecognition.h
@@ -0,0 +1,167 @@
+#ifndef _LPRECOGNITION_H_
+#define _LPRECOGNITION_H_
+
+
+#define LPR_API extern "C" __attribute__((visibility("default"))) 
+
+#define  LPR_OK               0   //初始化正确
+#define  LPR_KEY_ERROR       -1   //未找到加密狗
+
+
+
+//车牌类型
+typedef enum
+{
+	E_PT_NOTKNOWN,     //未知类型
+	E_PT_NORMAL_BLUE,  //普通蓝牌
+	E_PT_NORMAL_BLACK, //普通黑牌
+	E_PT_NORMAL_YELLOW,//普通单层黄牌
+	E_PT_DOUBLE_YELLOW,//双层黄牌
+	E_PT_POLICE,       //白色警牌
+	E_PT_WJ,           //白色武警
+	E_PT_ARMY,         //白色军牌
+	E_PT_GANG,         //港牌
+	E_PT_NONG,         //农用车牌----拖拉机
+	E_PT_ENERGY,       //新能源车----绿色
+	E_PT_ENERGY_Y,     //新能源车----黄色
+    E_PT_INDIVI,       //个性化车牌
+	E_PT_EMBASSY,      //使馆车
+	E_PT_YINGJI,       //应急车牌 
+}LPR_LPlateType;
+
+//车身颜色
+typedef enum
+{
+	E_VC_NOTKNOWN, //未知
+	E_VC_WHITE,    //白
+	E_VC_SILVER,   //灰
+	E_VC_YELLOW,   //黄
+	E_VC_RED,	  //红
+	E_VC_GREEN,    //绿
+	E_VC_BLUE,     //蓝
+	E_VC_BLACK,    //黑
+}LPR_LVehicleColor;
+
+typedef enum
+{
+	E_VC_DARK,  //深色
+	E_VC_LIGHT, //浅色
+}LPR_LVehicleBright;
+
+typedef enum
+{
+	E_LPR_RGB,
+	E_LPR_BGR,
+}LPR_ImageType;
+
+typedef struct  
+{
+	int iLeft;
+	int iTop;
+	int iRight;
+	int iBottom;
+}LPR_Rect;
+
+typedef struct 
+{
+	LPR_ImageType eImageType;  //图像类型
+	int iImageMode;           //0:为帧模式 1:为场模式
+	int iRecMode;             //识别模式,0:单张图片识别,1:视频检测+识别,2:视频多帧融合识别(注:1模式比2模式快,但识别率和捕获率比2低)
+	                          
+	int iResultNum;           //输出结果参数,最多支持输出4个结果
+	int iMinPlateWidth;       //识别最小车牌宽度
+	int iMaxPlateWidth;       //识别最大车牌宽度
+		
+	/******************矫正参数******************/
+	int iHorCorrect;  //是否做水平倾斜矫正,若不做水平倾斜矫正,则算法内部不会做垂直错切矫正
+	int iVerCorrect;  //是否做垂直错切矫正
+	
+	int iMinHorAngle; 
+	int iMaxHorAngle;//水平矫正角度范围,支持最大角度为[-30°,30°]
+	int iMinVerAngle;
+	int iMaxVerAngle;//垂直矫正角度范围,支持最大角度为[-30°,30°]
+
+	int iPlateBornThr;        //车牌输出帧数阈值:既车牌出现大于此帧数,则输出结果
+	int iPlateNumThr;         //车牌出现次数阈值:既车牌出现小于此数目,则不输出
+	int iPlateDeadThr;        //车牌消失帧数:针对视频应用,车牌消失大于此阈值,进行输出
+
+	int iImageWidth;          //图片宽度 
+	int iImageHeight;         //图片高度
+
+	char pLocalChinese[3];    //本地汉字字符,如果此字符设置为空或者31个省份之外的字,则不使用首汉字
+
+	//此些项针对车型识别有用,其余无用
+	float fExpLeftRightR;     //车脸左右扩充(车牌的宽度)倍数 参考值为1.6
+	float fExpTopR;           //车脸上部扩充(车牌的高度)倍数 参考值为6.0
+	float fExpBottomR;        //车脸下部扩充(车牌的高度)倍数 参考值为1.5
+}LPR_RecParma;
+
+typedef struct
+{
+	int iYear;
+	int iMonth;
+	int iDay;
+	int iHour;
+	int iMinute;
+	int iSecond;
+	int iMilliseconds;
+}LPR_Time;
+
+typedef struct  
+{
+	int iYear;
+	int iMonth;
+	int iDay;
+}LPR_DATE;
+typedef struct  
+{
+	char number[20];            //识别结果
+	LPR_Rect PlateRect;         //车牌位置
+	int x[4];
+	int y[4];
+	int iConfidence;            //车牌置信度
+	LPR_LPlateType ePlateType;  //车牌类型
+	int iMoveDir;               //车辆运动方向 0:朝近运动,1:朝远运动,-1:未知
+	LPR_LVehicleColor eVColor1; //车身主颜色
+	LPR_LVehicleColor eVColor2; //车身次颜色
+	LPR_LVehicleBright eVehicleBright; //车辆深浅色
+	unsigned char *pResultBits; //视频识别模式中抓拍的图片,视频模式识别下有效,需要开辟
+	
+	int iFramNo;                //视频模式下帧号
+	LPR_Time sTime;             //视频识别模式中抓拍此张图的时间
+	
+	//针对车脸识别应用此项,其余无用
+	unsigned char  *pVehicleFaceImage; //对应的车脸的图片,需要提前开辟内存,开辟个最大内存就可以,宽高可以都为1000
+	int iVehicleFaceWidth;             //车脸宽度
+	int iVehicleFaceHeight;            //车脸高度
+	int iGrayFaceFlag;                 //车脸是否为灰度图
+
+	LPR_Rect charLocation[20]; //车牌字符的位置(基于大图)
+	int charConfidence[20];    //字符识别置信度
+	int iCharNum;              //车牌字符数目
+}LPR_Result;
+
+LPR_API int LPR_ThreadInit(char* fullkeypath);
+
+LPR_API void LPR_SetRecThr(void* pInstance,int iThr); //设置车牌识别阈值:0~5,0最宽松,5最严格,默认为3
+
+LPR_API void* LPR_Init(LPR_RecParma RecParma);  //初始化,每个线程都必须调用一次
+
+LPR_API int   LPR_RecImage(unsigned char *pBits, int iWidth, int iHeight ,LPR_Result* pLprResult,LPR_Rect* recROI,void* pInstance);//识别
+
+LPR_API int   LPR_RecImage_mobile(unsigned char *pBits, int iWidth, int iHeight ,LPR_Result* pLprResult,LPR_Rect* recROI,void* pInstance);//识别
+
+LPR_API void  LPR_Uninit(void* pInstance);       //释放
+
+
+
+//云端识别接口
+LPR_API void* LPR_Cloud_Init(LPR_RecParma RecParma, char* fullModel);
+
+LPR_API int   LPR_Cloud_RecImage(unsigned char *pBits, int iWidth, int iHeight ,LPR_Result* pLprResult,LPR_Rect* recROI,void* pInstance);//识别
+
+LPR_API void  LPR_Cloud_Uninit(void* pInstance);       
+
+
+
+#endif
diff --git a/sdk/plate/cloud/lib/libLPRecognition.a b/sdk/plate/cloud/lib/libLPRecognition.a
new file mode 100644
index 0000000..e74c6ec
--- /dev/null
+++ b/sdk/plate/cloud/lib/libLPRecognition.a
Binary files differ
diff --git a/sdk/plate/cloud/lib/libLPRecognition.so b/sdk/plate/cloud/lib/libLPRecognition.so
new file mode 100644
index 0000000..2fcf6a4
--- /dev/null
+++ b/sdk/plate/cloud/lib/libLPRecognition.so
Binary files differ
diff --git a/sdk/plate/cloud/lib/libgfortran.so.3 b/sdk/plate/cloud/lib/libgfortran.so.3
new file mode 100644
index 0000000..9c64281
--- /dev/null
+++ b/sdk/plate/cloud/lib/libgfortran.so.3
Binary files differ
diff --git a/sdk/plate/cloud/lib/libopenblas.so.0 b/sdk/plate/cloud/lib/libopenblas.so.0
new file mode 100644
index 0000000..fc9bec2
--- /dev/null
+++ b/sdk/plate/cloud/lib/libopenblas.so.0
Binary files differ
diff --git a/sdk/plate/cloud/lib/plate_det.model b/sdk/plate/cloud/lib/plate_det.model
new file mode 100644
index 0000000..1e146be
--- /dev/null
+++ b/sdk/plate/cloud/lib/plate_det.model
Binary files differ
diff --git a/sdk/plate/include/TH_ErrorDef.h b/sdk/plate/eparking/include/TH_ErrorDef.h
similarity index 100%
rename from sdk/plate/include/TH_ErrorDef.h
rename to sdk/plate/eparking/include/TH_ErrorDef.h
diff --git a/sdk/plate/include/TH_PlateID.h b/sdk/plate/eparking/include/TH_PlateID.h
similarity index 100%
rename from sdk/plate/include/TH_PlateID.h
rename to sdk/plate/eparking/include/TH_PlateID.h
diff --git a/sdk/plate/lib/libLicenceManager.so b/sdk/plate/eparking/lib/libLicenceManager.so
similarity index 100%
rename from sdk/plate/lib/libLicenceManager.so
rename to sdk/plate/eparking/lib/libLicenceManager.so
Binary files differ
diff --git a/sdk/plate/lib/libthplateid.so b/sdk/plate/eparking/lib/libthplateid.so
similarity index 100%
rename from sdk/plate/lib/libthplateid.so
rename to sdk/plate/eparking/lib/libthplateid.so
Binary files differ

--
Gitblit v1.8.0