From 58a24b1c56d0d9db2aff1eedfb3ab79ea95718cb Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期三, 28 六月 2017 11:22:39 +0800
Subject: [PATCH] modify proto

---
 FaceServer/STFaceCache.cpp      |    6 +++---
 FaceServer/main_face_daemon.cpp |   34 ++++++++++++++++++++--------------
 FaceServer/face_daemon_proto.h  |    2 +-
 FaceServer/STFaceCache.h        |    2 ++
 FaceServer/proto_hton_ntoh.cpp  |    2 ++
 5 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/FaceServer/STFaceCache.cpp b/FaceServer/STFaceCache.cpp
index c603dca..b527a40 100644
--- a/FaceServer/STFaceCache.cpp
+++ b/FaceServer/STFaceCache.cpp
@@ -9,7 +9,7 @@
 #include "sample_face_search.h"
 #include <cv_face.h>
 
-#define FDP_FDR_INVALID FDP_FaceDetectResult(0, 0)
+#define FDP_FDR_INVALID FDP_FaceDetectResult(0, 0, 0)
 #define ENABLE_AUTO_CREATE_STFACEDB
 #define ENABLE_SEARCH_IN_NEGATIVE_DBID
 #define ENABLE_SEARCH_IN_NEGATIVE_DBID
@@ -254,7 +254,7 @@
 			return detect_neg(img);
 		}
 		
-		return FDP_FaceDetectResult(img.db_id, result[0].idx);
+		return FDP_FaceDetectResult(img.db_id, result[0].idx, result[0].score);
 	}
 
 	return FDP_FDR_INVALID;
@@ -318,5 +318,5 @@
 	if (idx <= 1)
 		return FDP_FDR_INVALID;
 	else
-		return FDP_FaceDetectResult(img.db_id, idx);
+		return FDP_FaceDetectResult(img.db_id, idx, 0);
 }
diff --git a/FaceServer/STFaceCache.h b/FaceServer/STFaceCache.h
index e8e0680..4a9f723 100644
--- a/FaceServer/STFaceCache.h
+++ b/FaceServer/STFaceCache.h
@@ -19,6 +19,8 @@
 	void close_dbs();
 	FDP_FaceDetectResult detect(const STFaceImage& img);
 	FDP_FaceDetectResult add(const STFaceImage& img);
+	fdr_vec_t search(const STFaceImage& img);
+	FDP_FaceDetectResult compare(const STFaceImage& img);
 	
 	//#todo need a delete img, if business not linked faceid and its personid
 	// they can delete it and save/find again!
diff --git a/FaceServer/face_daemon_proto.h b/FaceServer/face_daemon_proto.h
index 6bc5689..1ac3a8a 100644
--- a/FaceServer/face_daemon_proto.h
+++ b/FaceServer/face_daemon_proto.h
@@ -55,7 +55,7 @@
 	int32_t st_id; // sensetime id
 	int16_t confidence; // 1000 times of float confidence
 	
-	FDP_FaceDetectResult(int32_t _db_id, int32_t _st_id) : db_id(_db_id), st_id(_st_id), confidence(0)
+	FDP_FaceDetectResult(int32_t _db_id, int32_t _st_id, int _confidence) : db_id(_db_id), st_id(_st_id), confidence(_confidence)
 	{}
 	
 	void hton();
diff --git a/FaceServer/main_face_daemon.cpp b/FaceServer/main_face_daemon.cpp
index 7aa52a1..ec706f7 100644
--- a/FaceServer/main_face_daemon.cpp
+++ b/FaceServer/main_face_daemon.cpp
@@ -168,21 +168,27 @@
 	
 	LOGP(DEBUG, "stfaceImg2 db_id=%d, mb_type=%d, width=%d, height=%d, size=%d", 
 		(int)stfaceImg2.db_id, (int)stfaceImg2.mb_type, (int)stfaceImg2.width, (int)stfaceImg2.height, (int)stfaceImg2.size);
-		
-		
-	char imgfn[100 * 1024];
-	static int i = 0;
-	sprintf(imgfn, "IMG_%d_%d_w%d_h%d.img", stfaceImg1.db_id, ++i, stfaceImg1.width, stfaceImg1.height);
-	FILE * pFile = fopen(imgfn, "wb");
-	fwrite(stfaceImg1.buff, sizeof(char), stfaceImg1.size, pFile);
-	fclose(pFile);
-	pFile = nullptr;
 
-	sprintf(imgfn, "IMG_%d_%d_w%d_h%d.img", stfaceImg2.db_id, ++i, stfaceImg2.width, stfaceImg2.height);
-	pFile = fopen(imgfn, "wb");
-	fwrite(stfaceImg2.buff, sizeof(char), stfaceImg2.size, pFile);
-	fclose(pFile);
-	pFile = nullptr;
+	//char imgfn[100 * 1024];
+	//static int i = 0;
+	//sprintf(imgfn, "IMG_%d_%d_w%d_h%d.img", stfaceImg1.db_id, ++i, stfaceImg1.width, stfaceImg1.height);
+	//FILE * pFile = fopen(imgfn, "wb");
+	//fwrite(stfaceImg1.buff, sizeof(char), stfaceImg1.size, pFile);
+	//fclose(pFile);
+	//pFile = nullptr;
+    //
+	//sprintf(imgfn, "IMG_%d_%d_w%d_h%d.img", stfaceImg2.db_id, ++i, stfaceImg2.width, stfaceImg2.height);
+	//pFile = fopen(imgfn, "wb");
+	//fwrite(stfaceImg2.buff, sizeof(char), stfaceImg2.size, pFile);
+	//fclose(pFile);
+	//pFile = nullptr;
+	
+	//fdr_vec_t result;
+	//FDP_FaceDetectResult fdrResult = g_STFaceCache.add(stfaceImg);
+	//result.push_back(fdrResult);
+	//
+	//int ret = (fdrResult.db_id == 0 ? -1 : 0);
+	//return send_SensetimeFaceDetectResultJson(client, result, ret);
 }
 
 bool ev_dispatcher_proto_pb(EVClientStub& client)
diff --git a/FaceServer/proto_hton_ntoh.cpp b/FaceServer/proto_hton_ntoh.cpp
index 6abf5c2..ccc2da9 100644
--- a/FaceServer/proto_hton_ntoh.cpp
+++ b/FaceServer/proto_hton_ntoh.cpp
@@ -66,10 +66,12 @@
 {
 	db_id = htonl(db_id);
 	st_id = htonl(st_id);
+	confidence = htons(confidence);
 }
 
 void FDP_FaceDetectResult::ntoh()
 {
 	db_id = ntohl(db_id);
 	st_id = ntohl(st_id);
+	confidence = ntohs(confidence);
 }

--
Gitblit v1.8.0