From db043cb402515837303880cb0948d060e9d76490 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期一, 15 四月 2019 17:13:16 +0800
Subject: [PATCH] 整合代码
---
QiaoJiaSystem/StructureApp/AppPipeController.cpp | 137 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 120 insertions(+), 17 deletions(-)
diff --git a/QiaoJiaSystem/StructureApp/AppPipeController.cpp b/QiaoJiaSystem/StructureApp/AppPipeController.cpp
index 68383b4..14bfad1 100644
--- a/QiaoJiaSystem/StructureApp/AppPipeController.cpp
+++ b/QiaoJiaSystem/StructureApp/AppPipeController.cpp
@@ -9,7 +9,7 @@
#include <basic/pipe_element/ffmpeg/basic_struct_for_video_image.h>
//AppPipeController::AppPipeController(std::string folderPath, const Json::Value &json) :
-// videoCaptureElement("filePath", 25, -1, appPref.getLongData("gpu.index")), m_index(0),
+// videoCaptureElement("filePath", 25, -1, appPref.getIntData("gpu.index")), m_index(0),
// m_folderPath(folderPath),
// m_json(json), fdfsClient(nullptr), yoloRpcElement(folderPath + "yoloRpc"), faceRpcElement(folderPath + "faceRpc"),
// faceExtractElement(folderPath + "faceExtract"), triggerElement(25, 10),
@@ -19,14 +19,18 @@
//}
AppPipeController::AppPipeController(std::string folderPath, const SdkRuleMap &ruleMap) :
- m_rpcClient("RtspAnalysServer", "127.0.0.1", appPref.getIntData("RpcServerPort"), "tcp"),
- videoCaptureElement("filePath", 25, -1, appPref.getLongData("gpu.index")),
+ 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),
@@ -39,7 +43,7 @@
}
//AppPipeController::AppPipeController(int index, const Json::Value &json, bool RecordVideoEnable) :
-// videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getLongData("gpu.index"), RecordVideoEnable),
+// videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getIntData("gpu.index"), RecordVideoEnable),
// m_index(index), fdfsClient(nullptr), yoloRpcElement(to_string(index) + "yoloRpc"),
// faceRpcElement(to_string(index) + "faceRpc"), m_json(json), faceExtractElement(to_string(index) + "faceExtract"),
// triggerElement(25, 4), recordVideoElement(index, json["rtsp"].asString()), bRecordVideoEnable(RecordVideoEnable) {
@@ -48,7 +52,7 @@
//AppPipeController::AppPipeController(std::string camId, const Json::Value &json, bool RecordVideoEnable) :
-// videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getLongData("gpu.index")),
+// videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getIntData("gpu.index")),
// m_index(0),
// m_camId(camId),
// fdfsClient(nullptr),
@@ -69,13 +73,17 @@
// intKeepRight();
//}
AppPipeController::AppPipeController(std::string camId, const SdkRuleMap &ruleMap, bool RecordVideoEnable) :
- m_rpcClient("RtspAnalysServer", "127.0.0.1", appPref.getIntData("RpcServerPort"), "tcp"),
- videoCaptureElement(appPref.getStringData(camId + "rtsp"), 25, 3000, appPref.getLongData("gpu.index")),
+ 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");
@@ -258,7 +265,7 @@
std::string imgKey;
m_hiredisTool.listRpop(m_camId, imgKey);
if (imgKey.empty()) {
- ERR("CamId " << m_camId << " No ImgKey");
+// ERR("CamId "<<m_camId<<" No ImgKey");
return;
}
@@ -285,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()) {
@@ -344,6 +362,7 @@
});
+#ifdef YOLOSERVER
yoloRpcElement.registerConnector([&] {
imageDrawElement.setYoloObjects(personElement.getLastScoreRects());
if (!personElement.isBusy()) {
@@ -353,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());
@@ -360,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();
@@ -406,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));
@@ -474,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);
@@ -515,6 +569,7 @@
crowdElement.setProperty("local_ip", m_localIp);
+#ifdef YOLOSERVER
yoloRpcElement.registerConnector([&] {
if (!crowdElement.isBusy()) {
crowdElement.setYoloObjects(yoloRpcElement.getLastScoreRects());
@@ -522,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);
}
@@ -536,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());
@@ -550,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);
@@ -564,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());
@@ -571,7 +655,15 @@
perStaticElement.submit();
}
});
-
+#else
+ vptRpcElement.registerConnector([&] {
+ if (!perStaticElement.isBusy()) {
+ perStaticElement.setYoloObjects(vptRpcElement.getLastHpRects());
+ perStaticElement.setImage(vptRpcElement.getImage());
+ perStaticElement.submit();
+ }
+ });
+#endif
registerElement(perStaticElement);
}
@@ -584,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());
@@ -591,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