From 080afae264fe7ff89a54886f28dff208fe5a06c4 Mon Sep 17 00:00:00 2001 From: chenshijun <csj_sky@126.com> Date: 星期二, 16 四月 2019 22:01:35 +0800 Subject: [PATCH] 整合代码 --- QiaoJiaSystem/StructureApp/AppPipeController.cpp | 130 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 116 insertions(+), 14 deletions(-) diff --git a/QiaoJiaSystem/StructureApp/AppPipeController.cpp b/QiaoJiaSystem/StructureApp/AppPipeController.cpp index 45c7773..14bfad1 100644 --- a/QiaoJiaSystem/StructureApp/AppPipeController.cpp +++ b/QiaoJiaSystem/StructureApp/AppPipeController.cpp @@ -19,14 +19,18 @@ //} AppPipeController::AppPipeController(std::string folderPath, const SdkRuleMap &ruleMap) : - m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcVTIMPort"),"tcp"), + m_rpcClient("RtspAnalysServer", "127.0.0.1", appPref.getIntData("RpcVTIMPort"), "tcp"), videoCaptureElement("filePath", 25, -1, appPref.getIntData("gpu.index")), // videoCaptureElement(40), m_index(0), m_folderPath(folderPath), m_sdkRuleMap(ruleMap), fdfsClient(nullptr), +#ifdef YOLOSERVER yoloRpcElement(folderPath + "yoloRpc"), +#else + vptRpcElement(folderPath + "yoloRpc"), +#endif faceRpcElement(folderPath + "faceRpc", ruleMap[FaceSdk]), faceExtractElement(folderPath + "faceExtract", ruleMap[FaceSdk]), triggerElement(25, 10), @@ -69,13 +73,17 @@ // intKeepRight(); //} AppPipeController::AppPipeController(std::string camId, const SdkRuleMap &ruleMap, bool RecordVideoEnable) : - m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcVTIMPort"),"tcp"), + m_rpcClient("RtspAnalysServer", "127.0.0.1", appPref.getIntData("RpcVTIMPort"), "tcp"), videoCaptureElement(appPref.getStringData(camId + "rtsp"), 25, 3000, appPref.getIntData("gpu.index")), // videoCaptureElement(40), m_index(0), m_camId(camId), fdfsClient(nullptr), +#ifdef YOLOSERVER yoloRpcElement(camId + "yoloRpc"), +#else + vptRpcElement(camId + "yoloRpc"), +#endif faceRpcElement(camId + "faceRpc", ruleMap[FaceSdk]), faceExtractElement(camId + "faceExtract", ruleMap[FaceSdk]), triggerElement(25, 4), @@ -87,7 +95,7 @@ perHubElement(ruleMap[PerHubSdk]), leftJudgment(ruleMap[KeepRightSdk]), rightJudgment(ruleMap[KeepRightSdk]), - bRecordVideoEnable(RecordVideoEnable), +// bRecordVideoEnable(RecordVideoEnable), m_sdkRuleMap(ruleMap), m_bSetWH(false) { DBG("camId" << camId); @@ -175,7 +183,6 @@ string test_str; - void AppPipeController::RecordVideo() { /*std::string imgKeyYolo = yoloRpcElement.getProperty("imgKey"); @@ -256,9 +263,8 @@ videoCaptureElement.registerConnector([&] { std::string imgKey; - m_hiredisTool.listRpop(m_camId,imgKey); - if(imgKey.empty()) - { + m_hiredisTool.listRpop(m_camId, imgKey); + if (imgKey.empty()) { // ERR("CamId "<<m_camId<<" No ImgKey"); return; } @@ -286,19 +292,30 @@ //#todo faceRpcElement.setProperty("time", strNewTime); faceRpcElement.setProperty("imgKey", imgKey); - INFO("Write To FaceRPC ES time:" << strNewTime << " ImgKey: " << imgKey); +// INFO("Write To FaceRPC ES time:" << strNewTime << " ImgKey: " << imgKey); faceRpcElement.setImage(imageTemp); faceRpcElement.submit(); } +#ifdef YOLOSERVER if (!yoloRpcElement.isBusy()) { //#todo yoloRpcElement.setProperty("time", strNewTime); yoloRpcElement.setProperty("imgKey", imgKey); - INFO("Write To YoloES time:" << strNewTime << " ImgKey: " << imgKey); +// INFO("Write To YoloES time:" << strNewTime << " ImgKey: " << imgKey); yoloRpcElement.setImage(imageTemp); yoloRpcElement.submit(); } +#else + if (!vptRpcElement.isBusy()) { + //#todo + vptRpcElement.setProperty("time", strNewTime); + vptRpcElement.setProperty("imgKey", imgKey); + INFO("Write To vptRpcElement time:" << strNewTime << " ImgKey: " << imgKey); + vptRpcElement.setImage(imageTemp); + vptRpcElement.submit(); + } +#endif if (appPref.getIntData("show.image") == 1 && !imageDrawElement.isBusy()) { @@ -345,6 +362,7 @@ }); +#ifdef YOLOSERVER yoloRpcElement.registerConnector([&] { imageDrawElement.setYoloObjects(personElement.getLastScoreRects()); if (!personElement.isBusy()) { @@ -354,6 +372,19 @@ //INFO("Record Video By Yolo"); //this->RecordVideo(); }); +#else + vptRpcElement.registerConnector([&] { + imageDrawElement.setYoloObjects(personElement.getLastScoreRects()); + if (!personElement.isBusy()) { + personElement.setObjsResults(vptRpcElement.getLastHpRects()); + personElement.submit(); + } +//#todo HCP +//#todo Car + //INFO("Record Video By Yolo"); + //this->RecordVideo(); + }); +#endif faceRpcElement.registerConnector([&] { imageDrawElement.setFaces(faceRpcElement.getLastScoreRects()); @@ -361,11 +392,20 @@ //this->RecordVideo(); }); + +#ifdef YOLOSERVER yoloRpcElement.registerConnector("YoloTrigger", [&] { // auto images = yoloRpcElement.getTriggerMats(); //INFO("Record Video By Yolo"); //this->RecordVideo(); }); +#else + vptRpcElement.registerConnector("YoloTrigger", [&] { +// auto images = yoloRpcElement.getTriggerMats(); + //INFO("Record Video By Yolo"); + //this->RecordVideo(); + }); +#endif faceRpcElement.registerConnector("FaceTrigger", [&] { // auto images = faceRpcElement.getTriggerMats(); @@ -407,7 +447,11 @@ // registerElement(newRecordVideoElement); //videoCaptureElement.setOutPutInterval(3); faceExtractElement.setProperty("index", to_string(m_index)); +#ifdef YOLOSERVER registerElement(yoloRpcElement); +#else + registerElement(vptRpcElement); +#endif //#todo setProperty // faceExtractElement.setProperty("index", to_string(m_index)); // faceExtractElement.setProperty("index", to_string(m_index)); @@ -475,16 +519,25 @@ if (rule.nIsRun != 1) { return; } - - +#ifdef YOLOSERVER yoloRpcElement.registerConnector([&] { if (!perimeterElement.isBusy()) { perimeterElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); perimeterElement.setImage(yoloRpcElement.getImage()); - perimeterElement.submit(); } }); +#else + vptRpcElement.registerConnector([&] { + if (!perimeterElement.isBusy()) { + perimeterElement.setYoloObjects(vptRpcElement.getLastScoreRects()); + perimeterElement.setImage(vptRpcElement.getImage()); + perimeterElement.submit(); + } +// car +// prc + }); +#endif // perimeterElement.registerConnector([&] { // peTriggerElement.setState(perimeterElement.getRealNum() > 0); @@ -516,6 +569,7 @@ crowdElement.setProperty("local_ip", m_localIp); +#ifdef YOLOSERVER yoloRpcElement.registerConnector([&] { if (!crowdElement.isBusy()) { crowdElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); @@ -523,7 +577,17 @@ crowdElement.submit(); } }); - +#else + vptRpcElement.registerConnector([&] { + if (!perimeterElement.isBusy()) { + perimeterElement.setYoloObjects(vptRpcElement.getLastHpRects()); + perimeterElement.setImage(vptRpcElement.getImage()); + perimeterElement.submit(); + } +// car +// prc + }); +#endif registerElement(crowdElement); // registerElement(crowdTriggerElement); } @@ -537,6 +601,7 @@ rightJudgment.setProperty("local_ip", m_localIp); leftJudgment.init(rule.strAreas, rule.strLine); rightJudgment.init(rule.strExAreas, rule.strExLine); +#ifdef YOLOSERVER yoloRpcElement.registerConnector([&] { if (!leftJudgment.isBusy()) { leftJudgment.setYoloObjects(yoloRpcElement.getLastScoreRects()); @@ -551,6 +616,22 @@ } }); +#else + vptRpcElement.registerConnector([&] { + if (!leftJudgment.isBusy()) { + leftJudgment.setYoloObjects(vptRpcElement.getLastHpRects()); + leftJudgment.setImage(vptRpcElement.getImage()); + leftJudgment.submit(); + } + if (!rightJudgment.isBusy()) { + rightJudgment.setYoloObjects(vptRpcElement.getLastHpRects()); + + rightJudgment.setImage(vptRpcElement.getImage()); + rightJudgment.submit(); + } + }); +#endif + registerElement(leftJudgment); registerElement(rightJudgment); @@ -565,6 +646,8 @@ //area="[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]"; perStaticElement.setProperty("local_ip", m_localIp); + +#ifdef YOLOSERVER yoloRpcElement.registerConnector([&] { if (!perStaticElement.isBusy()) { perStaticElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); @@ -572,7 +655,15 @@ perStaticElement.submit(); } }); - +#else + vptRpcElement.registerConnector([&] { + if (!perStaticElement.isBusy()) { + perStaticElement.setYoloObjects(vptRpcElement.getLastHpRects()); + perStaticElement.setImage(vptRpcElement.getImage()); + perStaticElement.submit(); + } + }); +#endif registerElement(perStaticElement); } @@ -585,6 +676,8 @@ //area="[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]"; perHubElement.setProperty("local_ip", m_localIp); + +#ifdef YOLOSERVER yoloRpcElement.registerConnector([&] { if (!perHubElement.isBusy()) { perHubElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); @@ -592,6 +685,15 @@ perHubElement.submit(); } }); +#else + vptRpcElement.registerConnector([&] { + if (!perHubElement.isBusy()) { + perHubElement.setYoloObjects(vptRpcElement.getLastHpRects()); + perHubElement.setImage(vptRpcElement.getImage()); + perHubElement.submit(); + } + }); +#endif registerElement(perHubElement); } -- Gitblit v1.8.0