From c73d6fde347cfb6e0386ab1c651e8f38f939e89e Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期三, 06 三月 2019 11:49:03 +0800
Subject: [PATCH] GB28181集成完成。录像bug暂未解决,已注释
---
QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.h | 2
QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp | 298 +++++++++++++++++++++--------------------
QiaoJiaSystem/VideoToImageMulth/main.cpp | 3
QiaoJiaSystem/VideoAnalysFromHC/main.cpp | 13 +
QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp | 81 +++++------
5 files changed, 205 insertions(+), 192 deletions(-)
diff --git a/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp b/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp
index db552a4..be430a9 100644
--- a/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp
+++ b/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp
@@ -26,8 +26,8 @@
}
RtspAnalysElement::RtspAnalysElement(LDBTool *_dbTool) : m_lDBTool(_dbTool), maxCount(50), currentCount(0) {
- init();
resetFdfs();
+ init();
{
// std::thread httpServer([&]() {
// //#todo port
@@ -68,168 +68,174 @@
}
void RtspAnalysElement::init() {
+
+ m_GB28181_Enable = appPref.getIntData("GB28181_Enable");
+
Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo();
-#ifndef GB28181
- auto lst = m_lDBTool->searchCamDevTableAll();
- 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;
- int startCamNO = appPref.getIntData("CamStart") * appPref.getIntData("CamStep");
- int CamCount = appPref.getIntData("CamStep");
- auto itor = lst.begin();
+ //#todo GB28181
+ if (m_GB28181_Enable) {
+ auto lst = m_lDBTool->searchCamDevTableByType(1);
- 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 = rtspAddrBuild(itor->str_ip.toStdString(), 554, itor->str_username.toStdString(),
- itor->str_password.toStdString(), itor->str_brand.toStdString());
- SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(itor->str_cam_dev_id);
- for (auto &rule:ruleMap) {
-
- 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;
- 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 " << 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");
- }
-
-#else
- auto lst = m_lDBTool->searchCamDevTableByType(1);
-
- 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) {
+ 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();
- std::string rtsp_url = "GB28181";
+ for (auto &item : lst) {
+ std::string t_camIdex = item.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);
- for (auto &rule:ruleMap) {
+ 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);
+ 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;
+ 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;
+ } 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);
}
- DBG("fSensitivity" << rule.second.fSensitivity);
- }
- appPref.setStringData(t_camIdex + "rtsp", rtsp_url);
- // appPref.setStringData(t_camIdex+"addr", item.str_addr.toStdString());
+ 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();
+ // json["addr"] = item.str_addr.toStdString();
- INFO("cam add is " << item.str_addr.toStdString());
+ INFO("cam add is " << item.str_addr.toStdString());
- addCamera(t_camIdex, ruleMap);
+ addCamera(t_camIdex, ruleMap);
+ }
+ } else {
+ ERR("searchCamDevTableAll size is 0");
}
- } else {
- ERR("searchCamDevTableAll size is 0");
- }
-#endif
+ } else {
+
+ auto lst = m_lDBTool->searchCamDevTableAll();
+
+ 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;
+ int startCamNO = appPref.getIntData("CamStart") * appPref.getIntData("CamStep");
+ int CamCount = appPref.getIntData("CamStep");
+ 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 = rtspAddrBuild(itor->str_ip.toStdString(), 554, itor->str_username.toStdString(),
+ itor->str_password.toStdString(), itor->str_brand.toStdString());
+ SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(itor->str_cam_dev_id);
+ for (auto &rule:ruleMap) {
+
+ 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;
+ 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 " << 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");
+ }
+
+ }
}
+
RtspAnalysElement::~RtspAnalysElement() {
for (auto controller: controllers) {
delete controller.second;
diff --git a/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.h b/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.h
index 01d9abd..da7757a 100644
--- a/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.h
+++ b/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.h
@@ -44,7 +44,7 @@
private:
LDBTool *m_lDBTool;
-
+ int m_GB28181_Enable;
std::map<std::string, AppPipeController *> controllers;
std::atomic<int> currentCount;
int maxCount;
diff --git a/QiaoJiaSystem/VideoAnalysFromHC/main.cpp b/QiaoJiaSystem/VideoAnalysFromHC/main.cpp
index 3a39a22..87b89d5 100644
--- a/QiaoJiaSystem/VideoAnalysFromHC/main.cpp
+++ b/QiaoJiaSystem/VideoAnalysFromHC/main.cpp
@@ -77,7 +77,18 @@
DBG("hava GB28181");
#endif
- appPref.setLongData("gpu.index", 0);
+ if (argc < 4) {
+ assert("t_value.size()");
+ }
+
+ int arg1 = atoi(argv[1]);
+
+ int gindx = abs(arg1) % 2;
+ int GB28181_Enable = arg1 < 0 ? gindx : -1;
+ DBG(gindx);
+ appPref.setIntData("GB28181_Enable", GB28181_Enable);
+
+ appPref.setLongData("gpu.index", gindx);
appPref.setIntData("show.image", 0);
//todo
diff --git a/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp b/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp
index 7c814eb..8eafe6d 100644
--- a/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp
+++ b/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp
@@ -208,11 +208,6 @@
}
}
-#ifndef GB28181
-
-#else
-
-#endif
}
/**
@@ -222,24 +217,23 @@
*/
int RtspAnalysManager::removeCamera(const std::string &index) {
INFO("MYH DEBUG HERE");
-#ifndef GB28181
- if (m_controllers.find(index) == m_controllers.end())return -1;
- auto controller = m_controllers[index];
- controller->stop();
- controller->wait();
- delete controller;
- m_controllers.erase(index);
- m_currentCount--;
-
-#else
- if (m_controllers_videoCapElem.find(index) == m_controllers_videoCapElem.end())return -1;
- auto controller = m_controllers_videoCapElem[index];
- controller->stop();
- controller->wait();
- delete controller;
- m_controllers_videoCapElem.erase(index);
- m_currentCount--;
-#endif
+ if (m_GB28181_Enable) {
+ if (m_controllers_videoCapElem.find(index) == m_controllers_videoCapElem.end())return -1;
+ auto controller = m_controllers_videoCapElem[index];
+ controller->stop();
+ controller->wait();
+ delete controller;
+ m_controllers_videoCapElem.erase(index);
+ m_currentCount--;
+ } else {
+ if (m_controllers.find(index) == m_controllers.end())return -1;
+ auto controller = m_controllers[index];
+ controller->stop();
+ controller->wait();
+ delete controller;
+ m_controllers.erase(index);
+ m_currentCount--;
+ }
m_imgRedisCRwLock.wrlock();
auto imgRedis = m_imgRedisControllers[index];
@@ -258,25 +252,26 @@
*/
int RtspAnalysManager::removeAll() {
INFO("MYH DEBUG HERE");
-#ifndef GB28181
- for (auto controller: m_controllers) {
- controller.second->stop();
+
+ if (m_GB28181_Enable) {
+ for (auto controller: m_controllers_videoCapElem) {
+ controller.second->stop();
+ }
+ for (auto controller: m_controllers_videoCapElem) {
+ controller.second->wait();
+ delete controller.second;
+ }
+ m_controllers_videoCapElem.clear();
+ } else {
+ for (auto controller: m_controllers) {
+ controller.second->stop();
+ }
+ for (auto controller: m_controllers) {
+ controller.second->wait();
+ delete controller.second;
+ }
+ m_controllers.clear();
}
- for (auto controller: m_controllers) {
- controller.second->wait();
- delete controller.second;
- }
- m_controllers.clear();
-#else
- for (auto controller: m_controllers_videoCapElem) {
- controller.second->stop();
- }
- for (auto controller: m_controllers_videoCapElem) {
- controller.second->wait();
- delete controller.second;
- }
- m_controllers_videoCapElem.clear();
-#endif
INFO("MYH DEBUG HERE");
m_imgRedisCRwLock.wrlock();
@@ -311,11 +306,11 @@
INFO("Record Video For: " << name);
ImageName_s_t nameSt = ImageName_s_t::fromString(name);
if (nameSt.Valid()) {
- if (GB28181_Enable) {
+ if (m_GB28181_Enable) {
auto pCaptureElem = m_controllers_videoCapElem.find(nameSt.m_camId);
if (pCaptureElem != m_controllers_videoCapElem.end()) {
//#todo ~~~~~~!!!!!!! 杩欓噷鏈塨ug 闇�瑕佹斁寮�璋冭瘯
-// pCaptureElem->second->SaveVideo(name);
+// pCaptureElem->second->SaveVideo(name);
} else {
ERR("Can not Find CamId " << nameSt.m_camId);
}
diff --git a/QiaoJiaSystem/VideoToImageMulth/main.cpp b/QiaoJiaSystem/VideoToImageMulth/main.cpp
index fbc65f7..6403ebd 100644
--- a/QiaoJiaSystem/VideoToImageMulth/main.cpp
+++ b/QiaoJiaSystem/VideoToImageMulth/main.cpp
@@ -66,7 +66,8 @@
int arg1 = atoi(argv[1]);
int gindx = abs(arg1) % 2;
- int GB28181_Enable = abs(arg1) % 2;
+ int GB28181_Enable = arg1 < 0 ? gindx : -1;
+
DBG(gindx);
appPref.setIntData("GB28181_Enable", GB28181_Enable);
appPref.setLongData("gpu.index", gindx);
--
Gitblit v1.8.0