| | |
| | | #include <QtCore/QSharedMemory> |
| | | #include <basic/timer_counter/Clocktimer.h> |
| | | #include <THFeature_i.h> |
| | | //#include <basic/util/opencv/CvUtil.h> |
| | | |
| | | FaceExtractServerI::FaceExtractServerI() { |
| | | long threadMax = appPref.getIntData("thread.max"); |
| | |
| | | memcpy(&facesPos, &pos, sizeof(facesPos) - sizeof(facesPos.pFacialData)); |
| | | memcpy(facesPos.pFacialData, pos.pFacialData.data(), sizeof(facesPos.pFacialData)); |
| | | feature.resize(EF_Size()); |
| | | // INFO("faceExtract channel:" << channel << " width:" << width << " height:" << height); |
| | | |
| | | // { |
| | | // //#todo |
| | | // std::string string1(AppUtil::getTimeString() +".jpg"); |
| | | // DBG("save Image fe:" << string1); |
| | | // cv::Mat image(height, width, CV_8UC3, (u_char *)data); |
| | | // cv::imwrite(string1, image); |
| | | // |
| | | // cv::Rect area(facesPos.rcFace.left, facesPos.rcFace.top, \ |
| | | // facesPos.rcFace.right - facesPos.rcFace.left, facesPos.rcFace.bottom-facesPos.rcFace.top); |
| | | // cv::Mat img_region = image(area); |
| | | // std::string string2("face_" + string1); |
| | | // cv::imwrite(string2, img_region); |
| | | // } |
| | | INFO("facesPos:nQuality:" << facesPos.nQuality << "; rect[left:" << facesPos.rcFace.left << " top:" << \ |
| | | facesPos.rcFace.top << " right:" << facesPos.rcFace.right << " bottom:" << facesPos.rcFace.bottom << "]"); |
| | | int ret = EF_Extract(channel, (BYTE *) data, width, height, 3, &facesPos, feature.data()); |
| | | if (ret != 1) { |
| | | ERR("THFP_Execute_V2 faild, returns " << ret) |
| | |
| | | ERR("shareMemory attach faild"); |
| | | // throw std::runtime_error("shareMemory attach faild"); |
| | | } |
| | | return feature; |
| | | |
| | | } |
| | |
| | | IceRpcServer<FaceDetectServerI> server("faceServer", appPref.getIntData("RpcFDPort"), "tcp"); |
| | | server.setMessageSizeMax(1024 * 1024 * 50); |
| | | server.setPoolInitSize(appPref.getIntData("thread.max")); |
| | | server.setPoolMaxSize(appPref.getIntData("thread.max")); |
| | | DBG("MaxPoolSize: " << std::max(appPref.getIntData("thread.max")*2, 32)); |
| | | server.setPoolMaxSize(std::max(appPref.getIntData("thread.max")*2, 32)); |
| | | server.runWaitShutDown(); |
| | | return 0; |
| | | } |
| | |
| | | if (argc < 4) { |
| | | assert("t_value.size()"); |
| | | } |
| | | // appPref.setIntData("gpu.index", 0); |
| | | // appPref.setIntData("RpcFEPort", 10021); |
| | | // appPref.setIntData("thread.max", 1);//线程池大小 |
| | | |
| | | appPref.setIntData("gpu.index", atoi(argv[1])); |
| | | appPref.setIntData("RpcFEPort", atoi(argv[2])); |
| | | appPref.setIntData("thread.max", atoi(argv[3]));//线程池大小 |
| | |
| | | IceRpcServer<FaceExtractServerI> server("faceExtractServer", appPref.getIntData("RpcFEPort"), "tcp"); |
| | | server.setMessageSizeMax(1024 * 1024 * 50); |
| | | server.setPoolInitSize(appPref.getIntData("thread.max")); |
| | | server.setPoolMaxSize(appPref.getIntData("thread.max")); |
| | | DBG("MaxPoolSize: " << std::max(appPref.getIntData("thread.max")*2, 32)); |
| | | server.setPoolMaxSize(std::max(appPref.getIntData("thread.max")*2, 32)); |
| | | server.runWaitShutDown(); |
| | | return 0; |
| | | } |
| | |
| | | |
| | | unsigned long size = faceExtractQueueTmp[i].facesPos.size(); |
| | | for (int j = 0; j < size; j++) { |
| | | auto feature = extractServer->faceExtract(image.cols, image.rows, faceExtractQueueTmp[i].facesPos[j], |
| | | sharedMemory->key().toStdString()); |
| | | // { |
| | | // //#todo |
| | | // string string1( |
| | | // AppUtil::getTimeString() + "-ff3" + faceExtractQueueTmp[i].scoredRects[j].properties["time"] + |
| | | // ".jpg"); |
| | | // DBG("save Image:" << string1); |
| | | // cv::imwrite(string1, image); |
| | | // } |
| | | |
| | | auto feature = extractServer->faceExtract(image.cols, image.rows, faceExtractQueueTmp[i].facesPos[j], |
| | | sharedMemory->key().toStdString()); |
| | | |
| | | |
| | | if (feature.empty()) { |
| | | INFO("No Face Find: " << getProperty("imgKey")); |
| | | continue; |