From a3e29fd900f721007c60284ec76092a6154d4e19 Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期五, 21 四月 2017 11:03:51 +0800 Subject: [PATCH] add --- FaceServer/main_face_daemon.cpp | 53 +++++++++++++++++++++++++++++++++-------------------- 1 files changed, 33 insertions(+), 20 deletions(-) diff --git a/FaceServer/main_face_daemon.cpp b/FaceServer/main_face_daemon.cpp index 09f30e3..21da9f3 100644 --- a/FaceServer/main_face_daemon.cpp +++ b/FaceServer/main_face_daemon.cpp @@ -4,7 +4,7 @@ #include "ev_server.h" #include "ev_proto.h" #include "face_daemon_proto.h" - +#include "STFaceCache.h" #include <PbFaceList.pb.h> #include <signal.h> @@ -12,7 +12,10 @@ #include <sstream> #include <iostream> +#define WRAPPER_TEXT(x) "\"" << x << "\"" + Logger g_logger(std::cout); +STFaceCache g_STFaceCache("/opt/FaceServer/stfacedb"); evclient_proc_t evclient_proc; @@ -25,12 +28,12 @@ { std::stringstream ss; ss << "{" << std::endl; - ss << "\"ret\":" << 0 << "," << std::endl; - ss << "\"count\":" << result.size() << "," << std::endl; + ss << "\"ret\":" << WRAPPER_TEXT(0) << "," << std::endl; + ss << "\"count\":" << WRAPPER_TEXT(result.size()) << "," << std::endl; ss << "\"result\":["; for(fdr_vec_t::const_iterator iter = result.begin(); iter != result.end(); ++iter) { - ss << "[" << iter->db_id << "," << iter->st_id << "]"; + ss << "[" << WRAPPER_TEXT(iter->db_id) << "," << WRAPPER_TEXT(iter->st_id) << "]"; if (iter != std::prev(result.end())) ss << ","; } @@ -63,28 +66,38 @@ LOGP(DEBUG, "pbFaceList: magic=%u, image_count=%u, src_width=%u, src_height=%u", pbFaceList.magic(), pbFaceList.image_count(), pbFaceList.src_width(), pbFaceList.src_height()); + fdr_vec_t result; + for(int i = 0; i < pbFaceList.image_count(); i++) { const PbFaceList_FaceListImage& pbFaceListImage = pbFaceList.images(i); LOGP(DEBUG, "\tpbFaceList %d: idx=%u, size=%u, type=%u, width=%u, height=%u, top_left_x=%u, top_left_y=%u", i, pbFaceListImage.idx(), pbFaceListImage.size(), pbFaceListImage.type(), pbFaceListImage.width(), pbFaceListImage.height(), pbFaceListImage.top_left_x(), pbFaceListImage.top_left_y()); - - char imgfn[100 * 1024]; - sprintf(imgfn, "PB_%d_%d.yuv", 0, i); - - FILE * pFile = fopen(imgfn, "wb"); - fwrite(*(pbFaceListImage.img().data()), sizeof(char), pbFaceListImage.size(), pFile); - fclose(pFile); - pFile = nullptr; + + //#test + //char imgfn[100 * 1024]; + //sprintf(imgfn, "PB_%d_%d.yuv", 0, i); + // + //FILE * pFile = fopen(imgfn, "wb"); + const std::string* img(*pbFaceListImage.img().data()); + //fwrite(img->data(), sizeof(char), img->size(), pFile); + //fclose(pFile); + //pFile = nullptr; + + STFaceImage stimg; + stimg.db_id = fdpFaceDetectPB->db_id; + stimg.mb_type = pbFaceListImage.type(); + stimg.width = pbFaceListImage.width(); + stimg.height = pbFaceListImage.height(); + stimg.size = img->size(); + stimg.buff = (const uint8_t*)img->data(); + result.push_back(g_STFaceCache.detect(stimg)); } - - - fdr_vec_t result; - - //do detect(client) - result.push_back(FDP_FaceDetectResult(-1,123)); - result.push_back(FDP_FaceDetectResult(2,456)); - result.push_back(FDP_FaceDetectResult(0,0)); + + //#test + //result.push_back(FDP_FaceDetectResult(-1,123)); + //result.push_back(FDP_FaceDetectResult(2,456)); + //result.push_back(FDP_FaceDetectResult(0,0)); return send_SensetimeFaceDetectResultJson(client, result); } -- Gitblit v1.8.0