From d289fd8eb7a6581da0dd9c9963c15b6e7c08d744 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期二, 27 六月 2017 09:48:34 +0800
Subject: [PATCH] 

---
 FaceServer/sample_face_search.cpp |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/FaceServer/sample_face_search.cpp b/FaceServer/sample_face_search.cpp
index 25da1ac..93a6bdc 100644
--- a/FaceServer/sample_face_search.cpp
+++ b/FaceServer/sample_face_search.cpp
@@ -56,7 +56,6 @@
 cv_feature_t *stface_extract_feature(stface_handles& handles, const STFaceImage& image)
 {
 	cv_pixel_format stimgfmt = CV_PIX_FMT_GRAY8;
-	int matType = 0;
 	
 	if (image.width > MAX_FACE_IMAGE_WIDTH || image.height > MAX_FACE_IMAGE_HEIGHT)
 	{
@@ -73,7 +72,13 @@
 		
 		imgbufSize = image.height * image.width;
 		stimgfmt = CV_PIX_FMT_GRAY8;
-		matType = CV_8UC1;
+	}
+	else if (image.mb_type == MB_Frame::MBFT_NV12)
+	{
+		memcpy(imgbuf, image.buff, image.size);//#todo avoid mem cpy
+		
+		imgbufSize = image.height * image.width * 1.5;
+		stimgfmt = CV_PIX_FMT_NV12;
 	}
 	else if (image.mb_type == MB_Frame::MBFT_RGB565)
 	{
@@ -90,11 +95,10 @@
 			image.width, image.height
 			);
 		
-		imgbufSize = image.height * image.width;
-		stimgfmt = CV_PIX_FMT_GRAY8;
-		matType = CV_8UC1;
+		imgbufSize = image.height * image.width * 1.5;
+		stimgfmt = CV_PIX_FMT_YUV420P;
 	}
-	else if (image.mb_type == MB_Frame::MBFT_ABGR8888)
+	else if (image.mb_type == MB_Frame::MBFT_RGB888)
 	{
 		//int ret = libyuv::ARGBToBGRA(
 		//	image.buff, image.width * 4,
@@ -106,7 +110,6 @@
 		//
 		//imgbufSize = image.height * image.width * 4;
 		//stimgfmt = CV_PIX_FMT_BGRA8888;
-		//matType = CV_8UC4;
 
 		int ret = libyuv::ABGRToI400(
 				image.buff, image.width * 4,
@@ -118,7 +121,6 @@
 		
 		imgbufSize = image.height * image.width;
 		stimgfmt = CV_PIX_FMT_GRAY8;
-		matType = CV_8UC1;
 		
 		//{
 		//	static int f = 0;
@@ -152,21 +154,15 @@
     //    fwrite(imgbuf, 1, imgbufSize, pFile);
     //    fclose(pFile);
     //}
-	
-	Mat matImg(cv::Size(image.width, image.height), matType, imgbuf);
-	if (!matImg.data)
-	{
-		return nullptr;
-	}
-	
+
 	cv_feature_t *p_feature = nullptr;
 	cv_face_t *p_face = nullptr;
 	int face_count = 0;
 	cv_result_t result = CV_OK;
-	result = cv_face_detect(handles.handle_detect, matImg.data, stimgfmt, matImg.cols, matImg.rows, matImg.step, CV_FACE_UP, &p_face, &face_count);
+	result = cv_face_detect(handles.handle_detect, (unsigned char *)imgbuf, stimgfmt, image.width, image.height, image.width, CV_FACE_UP, &p_face, &face_count);
 	if (face_count >= 1)
 	{
-		result = cv_verify_get_feature(handles.handle_verify, (unsigned char *)matImg.data, stimgfmt, matImg.cols, matImg.rows, matImg.step, p_face, &p_feature, nullptr);
+		result = cv_verify_get_feature(handles.handle_verify, (unsigned char *)imgbuf, stimgfmt, image.width, image.height, image.width, p_face, &p_feature, nullptr);
 		if (result != CV_OK)
 		{
 			LOGP(DEBUG, "cv_verify_get_feature failed, error code %d", result);

--
Gitblit v1.8.0