From b8c5eb8048b566d632b25391a79ccbd6ce33c010 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期六, 30 三月 2019 16:10:01 +0800
Subject: [PATCH] 1.3 增加nsq消息,解决进程重启
---
QiaoJiaSystem/FaceDetectServer/FaceDetectServerI.cpp | 7 +
.gitignore | 2
QiaoJiaSystem/DataManagerServer/http_configserver.cpp | 13 ++-
QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp | 125 ++++++++++++------------------
QiaoJiaSystem/YoloServer/YoloDetectServerI.cpp | 2
QiaoJiaSystem/DataManagerServer/AppPipeController.cpp | 7 +
QiaoJiaSystem/VideoToImageMulth/main.cpp | 13 ++
QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp | 8 +-
QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp | 52 +++++++++++-
9 files changed, 131 insertions(+), 98 deletions(-)
diff --git a/.gitignore b/.gitignore
index d757c14..662f3db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,3 +56,5 @@
QiaoJiaSystem/build/\.fuse_hidden*
+
+QiaoJiaSystem/enctest/cmake-build-debug/
diff --git a/QiaoJiaSystem/DataManagerServer/AppPipeController.cpp b/QiaoJiaSystem/DataManagerServer/AppPipeController.cpp
index 91779a0..13df05b 100644
--- a/QiaoJiaSystem/DataManagerServer/AppPipeController.cpp
+++ b/QiaoJiaSystem/DataManagerServer/AppPipeController.cpp
@@ -1,17 +1,18 @@
#include "AppPipeController.h"
#include <basic/util/app/AppPreference.hpp>
+#include <basic/util/app/AppConfig.h>
#include <basic/util/app/AppUtil.h>
//#include <sstream>
#include <algorithm>
AppPipeController::AppPipeController(int index, const Json::Value &json):
videoCaptureElement(json["rtsp"].asString(), 25,3000,appPref.getIntData("gpu.index")),
index(index), videoPublishElement(appPref.getStringData("publish.basepath")+".flv",
- cv::Size(appPref.getIntData("pulish.width"),appPref.getIntData("pulish.height")),
+ cv::Size(appConfig.getIntProperty("pulish.width"),appConfig.getIntProperty("pulish.height")),
"flv", 25, appPref.getIntData("gpu.index"))
{
- if(appPref.getIntData("pulish.width") < 0 || appPref.getIntData("pulish.height") < 0)
+ if(appConfig.getIntProperty("pulish.width") < 0 || appConfig.getIntProperty("pulish.height") < 0)
{
- ERR("pulish.width: "<<appPref.getIntData("pulish.width") <<" Height: "<< appPref.getIntData("pulish.height"));
+ ERR("pulish.width: "<<appConfig.getIntProperty("pulish.width") <<" Height: "<< appConfig.getIntProperty("pulish.height"));
}
videoCaptureElement.registerConnector([&]{
//if(!videoPublishElement.isBusy()){
diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
index 615ff1b..b53818f 100644
--- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
+++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
@@ -22,6 +22,7 @@
#include <time.h>
#include <dirent.h>
#include "basic/pipe_element/ffmpeg/basic_struct_for_video_image.h"
+#include <basic/timer_counter/Clocktimer.h>
#include "vss/controller/VssDevTblController.h"
#include "vss/controller/VssChannelTblController.h"
@@ -1171,8 +1172,8 @@
std::string publish_basepath = rtmpAddr + "cam" + str_uuid;
DBG("publish_basepath:" << publish_basepath);
appPref.setStringData("publish.basepath", publish_basepath);
- appPref.setIntData("pulish.width", 640);
- appPref.setIntData("pulish.height", 360);
+// appPref.setIntData("pulish.width", 1920);
+// appPref.setIntData("pulish.height", 1080);
if (m_rtmp.find(ip) != m_rtmp.end()) {
if (m_rtmp[ip].appPC == nullptr) {
@@ -1224,8 +1225,8 @@
std::string publish_basepath = rtmpAddr + "cam" + str_uuid;
DBG("publish_basepath:" << publish_basepath);
appPref.setStringData("publish.basepath", publish_basepath);
- appPref.setIntData("pulish.width", 640);
- appPref.setIntData("pulish.height", 360);
+// appPref.setIntData("pulish.width", 1920);
+// appPref.setIntData("pulish.height", 1080);
if (m_rtmp.find(ip) != m_rtmp.end()) {
if (m_rtmp[ip].appPC == nullptr) {
@@ -2679,6 +2680,7 @@
std::string strSelectTemplate = R"#( -vf "select=eq(n\,%d)")#";
sprintf(selectExpBuff, strSelectTemplate.c_str(), frameIdDiff - 1);
if (videoSt.Valid() && imgSt.Valid()) {
+ ClockTimer clockTimer1("ffmpeg getpic");
std::string cmd("ffmpeg -i '" + videoPath + "'" + std::string(selectExpBuff) + " -vframes 1" + " -y '" +
str_imgName + "'");
INFO("Video To Image Cmd: " << cmd);
@@ -2688,17 +2690,20 @@
return "{\"error\":\"鏈煡鍒拌棰戣矾寰刓"}";
}
+ ClockTimer clockTimer2("cv::imread(str_imgName)");
cv::Mat img = cv::imread(str_imgName);
if (img.empty()) {
ERR("{\"error\":\"Video File error\"}");
return "{\"error\":\"瑙嗛鏂囦欢閿欒\"}";
}
+ ClockTimer clockTimer3("CvUtil::cvMat2Buffer(img, buffer)");
std::vector<unsigned char> buffer;
CvUtil::cvMat2Buffer(img, buffer);
std::string img_url = "http://";
fdfsClient.rwLock.rdlock();
if (fdfsClient.fastFds != nullptr) {
+ ClockTimer clockTimer4("fdfsClient.fastFds->uploadFile");
std::string t_strImg = "";
if (!fdfsClient.fastFds->uploadFile(buffer, t_strImg, "jpg")) {
img_url = "upload image fail";
diff --git a/QiaoJiaSystem/FaceDetectServer/FaceDetectServerI.cpp b/QiaoJiaSystem/FaceDetectServer/FaceDetectServerI.cpp
index 0c42a6d..dca9d2f 100644
--- a/QiaoJiaSystem/FaceDetectServer/FaceDetectServerI.cpp
+++ b/QiaoJiaSystem/FaceDetectServer/FaceDetectServerI.cpp
@@ -43,8 +43,8 @@
FaceDetect::Faces FaceDetectServerI::faceDetect(Ice::Int width, Ice::Int height, const std::string &shareMemoryName,
const Ice::Current &) {
- ClockTimer ct("FaceDetectServerI::faceDetect");
- INFO("Face Detect");
+// ClockTimer ct("FaceDetectServerI::faceDetect");
+// INFO("Face Detect");
FaceDetect::Faces faces;
QSharedMemory shareMemory(QString(shareMemoryName.c_str()));
if (shareMemory.attach()) {
@@ -53,6 +53,7 @@
int channel = detectResourcesManager.getAvilableChannel(shareMemoryName);
int faceNum = THFI_DetectFace(channel, (BYTE *) data, 24, width, height, facesPos, 30, m_ampleSize);
if (faceNum > 0) {
+ DBG("Face num is :" << faceNum);
for (int i = 0; i < faceNum; i++) {
FaceDetect::FacePos face;
auto &pos = facesPos[i];
@@ -63,7 +64,7 @@
faces.push_back(face);
}
} else {
- DBG("Face num is 0");
+// DBG("Face num is 0");
}
} else {
ERR("shareMemory error " << shareMemoryName);
diff --git a/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp b/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp
index faa86f6..e354f4e 100644
--- a/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp
+++ b/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp
@@ -80,17 +80,33 @@
appPref.setIntData("n_cut_max_duration", lst_dev.n_cut_max_duration);
appPref.setIntData("n_cut_min_duration", lst_dev.n_cut_min_duration);
if (lst.size() > 0) {
-// Json::Value json;
- for (auto &item : lst) {
- std::string t_camIdex = item.str_cam_dev_id.toStdString();
+ Json::Value json;
+ int startCamNO = appPref.getIntData("CamStartNO");
+ int CamCount = appPref.getIntData("CamEndNO") - appPref.getIntData("CamStartNO") + 1;
+ auto itor = lst.begin();
+
+ if (startCamNO >= lst.size()) {
+ ERR("startCamNO > lst.size()");
+ return;
+ }
+
+ for (int i = 0; i < startCamNO; i++) {
+ itor++;
+ }
+
+ for (int i = 0; i < CamCount; i++) {
+ if (itor == lst.end()) {
+ ERR("itor == lst.end()");
+ return;
+ }
+ std::string t_camIdex = itor->str_cam_dev_id.toStdString();
std::string rtsp_url = "GB28181";
-// rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(),
-// item.str_password.toStdString(), item.str_brand.toStdString());
- SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(item.str_cam_dev_id);
+
+ SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(itor->str_cam_dev_id);
for (auto &rule:ruleMap) {
- rule.second.strAddr = item.str_addr;
- rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first);
+ rule.second.strAddr = itor->str_addr;
+ rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(itor->str_cam_dev_id, rule.first);
if (rule.second.nSdkType == PerStaticSdk) {
float temp = 1 - (float) (rule.second.nThreshold) / 100;
@@ -103,14 +119,36 @@
DBG("fSensitivity" << rule.second.fSensitivity);
}
appPref.setStringData(t_camIdex + "rtsp", rtsp_url);
- // appPref.setStringData(t_camIdex+"addr", item.str_addr.toStdString());
-// json["rtsp"] = rtsp_url;
- // json["addr"] = item.str_addr.toStdString();
- INFO("cam add is " << item.str_addr.toStdString());
-
+ INFO("cam add is " << itor->str_addr.toStdString());
addCamera(t_camIdex, ruleMap);
+ itor++;
}
+
+// for (auto &item : lst) {
+// std::string t_camIdex = item.str_cam_dev_id.toStdString();
+// std::string rtsp_url = "GB28181";
+//
+// SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(item.str_cam_dev_id);
+// for (auto &rule:ruleMap) {
+//
+// rule.second.strAddr = item.str_addr;
+// rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first);
+//
+// if (rule.second.nSdkType == PerStaticSdk) {
+// float temp = 1 - (float) (rule.second.nThreshold) / 100;
+// rule.second.fSensitivity = (75 + 25 * temp) / 100;
+//
+// } else if (rule.second.nSdkType != FaceSdk) {
+// float temp = 1 - (float) (rule.second.nThreshold) / 100;
+// rule.second.fSensitivity = (5 + 90 * temp) / 100;
+// }
+// DBG("fSensitivity" << rule.second.fSensitivity);
+// }
+// appPref.setStringData(t_camIdex + "rtsp", rtsp_url);
+// INFO("cam add is " << item.str_addr.toStdString());
+// addCamera(t_camIdex, ruleMap);
+// }
} else {
ERR("searchCamDevTableAll size is 0");
}
@@ -158,76 +196,15 @@
float temp = 1 - (float) (rule.second.nThreshold) / 100;
rule.second.fSensitivity = (5 + 90 * temp) / 100;
}
- // if (rule.second.nThreshold < 5 )
- // {
- // rule.second.fSensitivity=0.95;
- // }
- // else if(rule.second.nThreshold > 95)
- // {
- // rule.second.fSensitivity=0.05;
- // }
- // else
- // {
- // rule.second.fSensitivity = 1-(float) (rule.second.nThreshold) / 100;
- // }
-
DBG("fSensitivity" << rule.second.fSensitivity);
}
appPref.setStringData(t_camIdex + "rtsp", rtsp_url);
- // appPref.setStringData(t_camIdex+"addr", item.str_addr.toStdString());
json["rtsp"] = rtsp_url;
- // json["addr"] = item.str_addr.toStdString();
INFO("cam add is " << itor->str_addr.toStdString());
-
addCamera(t_camIdex, ruleMap);
itor++;
}
- // for (auto item : lst) {
- // std::string t_camIdex = item.str_cam_dev_id.toStdString();
- // std::string rtsp_url = rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(),
- // item.str_password.toStdString(), item.str_brand.toStdString());
- // SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(item.str_cam_dev_id);
- // for (auto &rule:ruleMap) {
- //
- // rule.second.strAddr = item.str_addr;
- // rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first);
- //
- // if(rule.second.nSdkType == PerStaticSdk)
- // {
- // float temp=1-(float)(rule.second.nThreshold)/100;
- // rule.second.fSensitivity=(75+25*temp)/100;
- //
- // }
- // else if(rule.second.nSdkType != FaceSdk)
- // {
- // float temp=1-(float)(rule.second.nThreshold)/100;
- // rule.second.fSensitivity=(5+90*temp)/100;
- // }
- //// if (rule.second.nThreshold < 5 )
- //// {
- //// rule.second.fSensitivity=0.95;
- //// }
- //// else if(rule.second.nThreshold > 95)
- //// {
- //// rule.second.fSensitivity=0.05;
- //// }
- //// else
- //// {
- //// rule.second.fSensitivity = 1-(float) (rule.second.nThreshold) / 100;
- //// }
- //
- // DBG("fSensitivity" << rule.second.fSensitivity);
- // }
- // appPref.setStringData(t_camIdex + "rtsp", rtsp_url);
- // // appPref.setStringData(t_camIdex+"addr", item.str_addr.toStdString());
- // json["rtsp"] = rtsp_url;
- // // json["addr"] = item.str_addr.toStdString();
- //
- // INFO("cam add is " << item.str_addr.toStdString());
- //
- // addCamera(t_camIdex, ruleMap);
- // }
} else {
ERR("searchCamDevTableAll size is 0");
}
diff --git a/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp b/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp
index 01b854a..d786f47 100644
--- a/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp
+++ b/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp
@@ -44,10 +44,29 @@
DBG("searchCamDevTableByType size:" << lst.size());
if (lst.size() > 0) {
- for (auto item : lst) {
- std::string t_camIdex = item.str_cam_dev_id.toStdString();
+ int startCamNO = appPref.getIntData("CamStartNO");
+ int CamCount = appPref.getIntData("CamEndNO") - appPref.getIntData("CamStartNO") + 1;
+ INFO("StartCamNO: " << startCamNO << " CamCount: " << CamCount);
+ auto itor = lst.begin();
+
+ if (startCamNO >= lst.size()) {
+ ERR("startCamNO > lst.size()");
+ return;
+ }
+
+ for (int i = 0; i < startCamNO; i++) {
+ itor++;
+ }
+
+ for (int i = 0; i < CamCount; i++) {
+ if (itor == lst.end()) {
+ ERR("itor == lst.end()");
+ return;
+ }
+ std::string t_camIdex = itor->str_cam_dev_id.toStdString();
DBG("-----camID:" << t_camIdex << "min:" << cut_min_duration << "max:" << cut_max_duration);
pthis->m_controllers_videoCapElem[t_camIdex]->SetVideoMinMaxSeconds(cut_min_duration, cut_max_duration);
+ itor++;
}
} else {
ERR("searchCamDevTableByType size is 0");
@@ -127,14 +146,33 @@
appPref.setIntData("n_cut_max_duration", lst_dev.n_cut_max_duration);
appPref.setIntData("n_cut_min_duration", lst_dev.n_cut_min_duration);
if (lst.size() > 0) {
- for (auto item : lst) {
- std::string t_camIdex = item.str_cam_dev_id.toStdString();
+ int startCamNO = appPref.getIntData("CamStartNO");
+ int CamCount = appPref.getIntData("CamEndNO") - appPref.getIntData("CamStartNO") + 1;
+ INFO("StartCamNO: " << startCamNO << " CamCount: " << CamCount);
+ auto itor = lst.begin();
+
+ if (startCamNO >= lst.size()) {
+ ERR("startCamNO > lst.size()");
+ return;
+ }
+
+ for (int i = 0; i < startCamNO; i++) {
+ itor++;
+ }
+
+ for (int i = 0; i < CamCount; i++) {
+ if (itor == lst.end()) {
+ ERR("itor == lst.end()");
+ return;
+ }
+ std::string t_camIdex = itor->str_cam_dev_id.toStdString();
std::string rtsp_url = "GB28181";
-// rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(),
-// item.str_password.toStdString(), item.str_brand.toStdString());
- INFO("cam add is " << item.str_addr.toStdString());
+
+ INFO("cam add is " << itor->str_addr.toStdString());
+
addCamera(t_camIdex, rtsp_url);
sleep(1);
+ itor++;
}
} else {
ERR("searchCamDevTableByType size is 0");
diff --git a/QiaoJiaSystem/VideoToImageMulth/main.cpp b/QiaoJiaSystem/VideoToImageMulth/main.cpp
index cc8e031..bf77930 100644
--- a/QiaoJiaSystem/VideoToImageMulth/main.cpp
+++ b/QiaoJiaSystem/VideoToImageMulth/main.cpp
@@ -66,8 +66,8 @@
// std::string rtmpAddr = appConfig.getStringProperty("srsAddr");
// std::string publish_basepath = rtmpAddr + "" ;
// appPref.setStringData("publish.basepath", publish_basepath);
- appPref.setIntData("pulish.width", 640);
- appPref.setIntData("pulish.height", 360);
+// appPref.setIntData("pulish.width", 640);
+// appPref.setIntData("pulish.height", 480);
}
// int arg1 = atoi(argv[1]);
//
@@ -113,8 +113,13 @@
BaseSqliteDao::setLDBTool(&ldbTool);
t_value = VssLocalSettingTblSqliteDao::instance()->findAllVssLocalSettingTblList();
}
+ DBG("t_value.size():" << t_value.size());
+ DBG("t_value[\"data\"].size():" << t_value["data"].size());//todo bug here t_value["data"].size() = 0
if (t_value.size() == 1 && t_value["data"].size() > 1) {
assert("t_value.size()");
+ }
+ if (t_value["data"].size() == 0) {
+ assert("t_value[\"data\"].size()");
}
DBG(t_value["data"].begin()->toStyledString());
auto &t_cfg = *t_value["data"].begin();
@@ -160,6 +165,10 @@
}
DBG("test start");
+ // #todo
+// BasicMsg::Nsq::NsqMsgConsumer nsqMsgConsumer("127.0.0.1", "4150", "test3", "ch2");
+ //
+
appPref.setStringData("user.loop.absolute.path", appConfig.getStringProperty("cutPath"));
IceRpcServer<RtspAnalysManager> server("RtspAnalysServer", appPref.getIntData("RpcVTIMPort"), "tcp");
server.setMessageSizeMax(1024 * 1024 * 50);
diff --git a/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp b/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp
index 06191c5..2bf9968 100644
--- a/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp
+++ b/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp
@@ -13,12 +13,12 @@
videoPublishElement(nullptr) {
string path = appConfig.getStringProperty("srsAddr") + "cam" + chanPubID + ".flv";
- cv::Size size_(appPref.getIntData("pulish.width"), appPref.getIntData("pulish.height"));
+ cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height"));
int gupIdx = appPref.getIntData("gpu.index");
videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx);
- if (appPref.getIntData("pulish.width") < 0 || appPref.getIntData("pulish.height") < 0) {
- ERR("pulish.width: " << appPref.getIntData("pulish.width") << " Height: "
- << appPref.getIntData("pulish.height"));
+ if (appConfig.getIntProperty("pulish.width") < 0 || appConfig.getIntProperty("pulish.height") < 0) {
+ ERR("pulish.width: " << appConfig.getIntProperty("pulish.width") << " Height: "
+ << appConfig.getIntProperty("pulish.height"));
}
videoCaptureElement.registerConnector([&] {
//if(!videoPublishElement.isBusy()){
diff --git a/QiaoJiaSystem/YoloServer/YoloDetectServerI.cpp b/QiaoJiaSystem/YoloServer/YoloDetectServerI.cpp
index 823365f..545bf5f 100644
--- a/QiaoJiaSystem/YoloServer/YoloDetectServerI.cpp
+++ b/QiaoJiaSystem/YoloServer/YoloDetectServerI.cpp
@@ -14,7 +14,7 @@
::YoloDetect::ObjInfos
YoloDetectServerI::YoloDetect(::Ice::Int w, ::Ice::Int h, const ::std::string &shM, const ::Ice::Current &) {
- ClockTimer ct("YoloDetectServerI::YoloDetect");
+// ClockTimer ct("YoloDetectServerI::YoloDetect");
// std::thread::id key = std::this_thread::get_id();
// DBG("key is " << key);
--
Gitblit v1.8.0