From 004e5b3424f02b2b413a52d7162594c4cc5c5547 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期三, 28 六月 2017 14:02:52 +0800
Subject: [PATCH] add compare bin proto

---
 FaceServer/sample_face_search.cpp |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/FaceServer/sample_face_search.cpp b/FaceServer/sample_face_search.cpp
index 93a6bdc..ac36fc4 100644
--- a/FaceServer/sample_face_search.cpp
+++ b/FaceServer/sample_face_search.cpp
@@ -133,6 +133,17 @@
 		//	fclose(pFile);
 		//}
 	}
+	else if (image.mb_type == MB_Frame::MBFT_JPEG)
+	{
+		Mat matTmp = imdecode(_InputArray(image.buff, image.size), CV_LOAD_IMAGE_COLOR);
+		
+		//imwrite("aaa.jpg", matTmp);
+
+		imgbufSize = matTmp.total() * matTmp.elemSize();
+		memcpy(imgbuf, matTmp.ptr(), imgbufSize);
+
+		stimgfmt = CV_PIX_FMT_BGR888;
+	}
 	else
 	{
 		LOG_WARN << "mb frame type not support" << LOG_ENDL;
@@ -178,6 +189,35 @@
 	return p_feature;
 }
 
+float stface_compare(stface_handles& handles, const STFaceImage& image1, const STFaceImage& image2)
+{
+	cv_feature_t* f1 = stface_extract_feature(handles, image1);
+	if (f1 == nullptr)
+	{
+		LOGP(INFO, "can't find face in image1");
+		return -1.0;
+	}
+	
+	cv_feature_t* f2 = stface_extract_feature(handles, image2);
+	if (f2 == nullptr)
+	{
+		cv_verify_release_feature(f1);
+		LOGP(INFO, "can't find face in image1");
+		return -1.0;
+	}
+
+	float score = -1.0;
+	cv_result_t cv_result = cv_verify_compare_feature(handles.handle_verify, f1, f2, &score);
+	if (cv_result != CV_OK) {
+		LOGP(DEBUG, "cv_verify_compare_feature failed, error code %d", cv_result);
+		score = -1.0;
+	}
+	
+	cv_verify_release_feature(f1);
+	cv_verify_release_feature(f2);
+	return score;
+}
+
 int stface_db_add(stface_handles& handles, const char *image_path) {
 	cv_feature_t *p_feature = stface_extract_feature(handles, image_path);
 	if (!p_feature) {

--
Gitblit v1.8.0