Browse Source

Fix cmake file

qiuyang 2 tháng trước cách đây
mục cha
commit
d4c6dcd5e0

+ 3 - 0
framework/request/include/HepuTarget.h

@@ -12,6 +12,9 @@ class HepuTarget
 {
     private:
     public:
+        using Ptr = std::shared_ptr<HepuTarget>;
+
+    public:
         const string cmd = "ivpTrackingCtrl";
         string token;
         bool bTracking;

BIN
lib/libgsd_core.so


BIN
lib/libgsd_modules.so


BIN
lib/libgsd_plugins.so


+ 18 - 18
modules/CMakeLists.txt

@@ -16,15 +16,15 @@ endif()
 # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror")
 
 # ---[ Options
-option(build_Expel "build module Expel" OFF)
-option(build_HttpClient "build module HttpClient" OFF)
-option(build_InfineFilter "build module InfineFilter" OFF)
-option(build_Monitor "build module Monitor" OFF)
-option(build_TCPClient "build module TCPClient" OFF)
-option(build_config "build module config" OFF)
-option(build_HttpServer "build module HttpServer" OFF)
-option(build_Audit "build module Audit" OFF)
-option(build_kafka "build module kafka" OFF)
+option(build_Expel "build module Expel" ON)
+option(build_HttpClient "build module HttpClient" ON)
+option(build_InfineFilter "build module InfineFilter" ON)
+option(build_Monitor "build module Monitor" ON)
+option(build_TCPClient "build module TCPClient" ON)
+option(build_config "build module config" ON)
+option(build_HttpServer "build module HttpServer" ON)
+option(build_Audit "build module Audit" ON)
+option(build_kafka "build module kafka" ON)
 option(build_Hepu "build module Hepu" ON)
 
 # ---[ 3rdparty
@@ -51,47 +51,47 @@ set(srcs "")
 
 if(build_Expel)
   list(APPEND module_list Expel)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/Expel/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/Expel/src)
   install(DIRECTORY Expel/include/ DESTINATION include)
 endif()
 if(build_InfineFilter)
   list(APPEND module_list InfineFilter)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/InfineFilter/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/InfineFilter/src)
   install(DIRECTORY InfineFilter/include/ DESTINATION include)
 endif()
 if(build_Monitor)
   list(APPEND module_list Monitor)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/Monitor/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/Monitor/src)
   install(DIRECTORY Monitor/include/ DESTINATION include)
 endif()
 if(build_TCPClient)
   list(APPEND module_list TCPClient)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/TCPClient/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/TCPClient/src)
   install(DIRECTORY TCPClient/include/ DESTINATION include)
 endif()
 if(build_config)
   list(APPEND module_list config)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/config/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/config/src)
   install(DIRECTORY config/include/ DESTINATION include)
 endif()
 if(build_HttpClient)
   list(APPEND module_list HttpClient)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/HttpClient/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/HttpClient/src)
   install(DIRECTORY HttpClient/include/ DESTINATION include)
 endif()
 if(build_HttpServer)
   list(APPEND module_list HttpServer)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/HttpServer/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/HttpServer/src)
   install(DIRECTORY HttpServer/include/ DESTINATION include)
 endif()
 if(build_Hepu)
   list(APPEND module_list Hepu)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/Hepu/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/Hepu/src)
   install(DIRECTORY Hepu/include/ DESTINATION include)
 endif()
 if(build_Audit)
   list(APPEND module_list Audit)
-  include_directories(${PROJECT_SOURCE_DIR}/modules/Audit/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/modules/Audit/src)
   install(DIRECTORY Audit/include/ DESTINATION include)
 endif()
 

+ 3 - 0
modules/Hepu/src/Hepu.cpp

@@ -131,6 +131,9 @@ namespace gsd{
 
         std::string msg;
         HepuTargetMsg.token = this->token;
+        HepuTargetMsg.channelid = 1;
+        HepuTargetMsg.bTracking = true;
+        HepuTargetMsg.trackingTime = 0;
         HepuTargetMsg.objectToJson(msg);
         msg+="\r\n";
         

+ 8 - 0
modules/config/include/config.hpp

@@ -95,6 +95,14 @@ public:
     std::string InferCheckerIP = "192.168.31.219";
     int InferCheckerPort = 8860;
 
+    int Hepu = 0;
+    
+    std::string HepuIP = "192.168.0.36";
+    int HepuPort = 80;
+    std::string HepuURL = "/cgi-bin/proc.cgi";
+    std::string HepuUsr = "sunwin";
+    std::string HepuPwd = "123456";
+
 protected:
     #ifdef RELEASE
         std::string configFile = "/etc/gsd/config.ini";

+ 7 - 0
modules/config/src/config.cpp

@@ -66,6 +66,13 @@ bool config::Update(){
     this->payServerIP_tcp = m_ini.getStringValue("payServer", "IP", ret);
     this->payServerPort_tcp = m_ini.getIntValue("payServer", "Port", ret);
 
+    this->Hepu = m_ini.getIntValue("Hepu","enable",ret);
+    this->HepuIP = m_ini.getStringValue("Hepu","hepu_ip",ret);
+    this->HepuPort = m_ini.getIntValue("Hepu","hepu_port",ret);
+    this->HepuURL = m_ini.getStringValue("Hepu","hepu_url",ret);
+    this->HepuUsr = m_ini.getStringValue("Hepu","hepu_usr",ret);
+    this->HepuPwd = m_ini.getStringValue("Hepu","hepu_pwd",ret);
+
     this->SimCode = this->getSimCode();
     this->app = this->getApp();
     

+ 17 - 17
plugins/CMakeLists.txt

@@ -16,13 +16,13 @@ endif()
 # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror")
 
 # ---[ Options
-option(build_ExpelPlugin "build module ExpelPlugin" OFF)
-option(build_HttpPlugin "build module HttpPlugin" OFF)
-option(build_MonitorPlugin "build module MonitorPlugin" OFF)
-option(build_TcpPlugin "build module TcpPlugin" OFF)
-option(build_AuditPlugin "build module AuditPlugin" OFF)
+option(build_ExpelPlugin "build module ExpelPlugin" ON)
+option(build_HttpPlugin "build module HttpPlugin" ON)
+option(build_MonitorPlugin "build module MonitorPlugin" ON)
+option(build_TcpPlugin "build module TcpPlugin" ON)
+option(build_AuditPlugin "build module AuditPlugin" ON)
 option(build_HepuPlugin "build module HepuPlugin" ON)
-option(build_kafka "build module kafka" OFF)
+option(build_kafka "build module kafka" ON)
 
 
 # ---[ 3rdparty
@@ -45,12 +45,12 @@ include_directories(${GSD_ROOT_DIR}/framework/core/include)
 include_directories(${GSD_ROOT_DIR}/framework/request/include)
 include_directories(${GSD_ROOT_DIR}/modules/Expel/include)
 include_directories(${GSD_ROOT_DIR}/modules/HttpClient/include)
+include_directories(${GSD_ROOT_DIR}/modules/Hepu/include)
 include_directories(${GSD_ROOT_DIR}/modules/InfineFilter/include)
 include_directories(${GSD_ROOT_DIR}/modules/Monitor/include)
 include_directories(${GSD_ROOT_DIR}/modules/TCPClient/include)
 include_directories(${GSD_ROOT_DIR}/modules/HttpServer/include)
 include_directories(${GSD_ROOT_DIR}/modules/config/include)
-include_directories(${GSD_ROOT_DIR}/modules/Hepu/include)
 include_directories(${GSD_ROOT_DIR}/modules/Audit/include)
 
 set(module_list "")
@@ -58,32 +58,32 @@ set(srcs "")
 
 if(build_ExpelPlugin)
   list(APPEND module_list ExpelPlugin)
-  include_directories(${PROJECT_SOURCE_DIR}/plugins/ExpelPlugin/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/plugins/ExpelPlugin/src)  
   install(DIRECTORY ExpelPlugin/include/ DESTINATION include)
 endif()
 if(build_HttpPlugin)
   list(APPEND module_list HttpPlugin)
-  include_directories(${PROJECT_SOURCE_DIR}/plugins/HttpPlugin/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/plugins/HttpPlugin/src)
   install(DIRECTORY HttpPlugin/include/ DESTINATION include)
 endif()
+if(build_HepuPlugin)
+  list(APPEND module_list HepuPlugin)
+  #include_directories(${PROJECT_SOURCE_DIR}/plugins/HepuPlugin/src)
+  install(DIRECTORY HepuPlugin/include/ DESTINATION include)
+endif()
 if(build_MonitorPlugin)
   list(APPEND module_list MonitorPlugin)
-  include_directories(${PROJECT_SOURCE_DIR}/plugins/MonitorPlugin/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/plugins/MonitorPlugin/src)
   install(DIRECTORY MonitorPlugin/include/ DESTINATION include)
 endif()
 if(build_TcpPlugin)
   list(APPEND module_list TcpPlugin)
-  include_directories(${PROJECT_SOURCE_DIR}/plugins/TcpPlugin/src)
+  #include_directories(${PROJECT_SOURCE_DIR}/plugins/TcpPlugin/src)
   install(DIRECTORY TcpPlugin/include/ DESTINATION include)
 endif()
-if(build_HepuPlugin)
-  list(APPEND module_list HepuPlugin)
-  include_directories(${PROJECT_SOURCE_DIR}/plugins/HepuPlugin/src)
-  install(DIRECTORY HepuPlugin/include/ DESTINATION include)
-endif()
 if(build_AuditPlugin)
   list(APPEND module_list AuditPlugin)
-  include_directories(${PROJECT_SOURCE_DIR}/plugins/AuditPlugin/src)
+  # include_directories(${PROJECT_SOURCE_DIR}/plugins/AuditPlugin/src)
   install(DIRECTORY AuditPlugin/include/ DESTINATION include)
 endif()
 

+ 3 - 1
plugins/HepuPlugin/include/HepuPlugin.hpp

@@ -9,7 +9,7 @@
 #include "Util/logger.h"
 #include "Util/TimeTicker.h"
 #include "Util/NoticeCenter.h"
-//#include "HttpClient.hpp"
+#include "config.hpp"
 #include "requests.hpp"
 #include "Hepu.hpp"
 #include "PluginSubscriber.hpp"
@@ -42,6 +42,8 @@ namespace gsd
 
             void HBThrd();
 
+            void SendTarget(HepuTarget& HepuTargetMsg);
+
             bool Alive();
 
             virtual bool RestPlugin();

+ 19 - 4
plugins/HepuPlugin/src/HepuPlugin.cpp

@@ -9,12 +9,14 @@ namespace gsd
     }
 
     bool HepuPlugin::Init(){
-        cout<<"Creat HEPU object."<<endl;
+        if(config::getPtr()->Hepu == 0)
+            return false;
+
         if(this->m_hepuClient == nullptr){
             this->m_hepuClient = Hepu::CreateNew();
         }
 
-        cout<<"Connect to IPC"<<endl;
+        
         if(this->m_hepuClient->Init(HEPU_USR,HEPU_IP,HEPU_PORT) == OK){
             InfoL << "Hepu IPC http login succeeds."<<endl;
         }else{
@@ -44,11 +46,24 @@ namespace gsd
 
     void HepuPlugin::HBThrd(){
         InfoL<<"Send Heartbeat "<<endl;
-        if(this->m_hepuClient == nullptr) return;
-        this->m_hepuClient->sendHepuHB();
+        if(this->m_hepuClient == nullptr)
+        {
+            this->RestPlugin();
+        }
+        else
+        {
+            this->m_hepuClient->sendHepuHB();
+        }
         sleep(10);
     }
 
+    void HepuPlugin::SendTarget(HepuTarget& HepuTargetMsg){
+        InfoL<<"Send target command."<<endl;
+        if(this->m_hepuClient == nullptr) return;
+        this->m_hepuClient->sendHepuTarget(HepuTargetMsg);
+        return;
+    }
+
     void HepuPlugin::Destroy(){
         InfoL<<"Hepu IPC httpclient plugin destroyed"<<endl;
         stop_ = true;

+ 2 - 1
plugins/MonitorPlugin/include/MonitorPlugin.hpp

@@ -10,6 +10,7 @@
 #include "InfineFilter.hpp"
 #include "HttpPlugin.hpp"
 #include "PluginSubscriber.hpp"
+#include "HepuPlugin.hpp"
 
 using namespace std;
 
@@ -66,7 +67,7 @@ namespace gsd
          * @param {Ptr&} result
          * @return {*}
          */    
-        bool ConsumeData(FrameInferData::Ptr& result);
+        bool ConsumeData(FrameInferData::Ptr& result, HepuTarget::Ptr& target);
 
         /**
         * @description: 保存视频记录

+ 38 - 2
plugins/MonitorPlugin/src/MonitorPlugin.cpp

@@ -55,7 +55,8 @@ namespace gsd
      */
     void MonitorPlugin::MonitorProThrd(){
         FrameInferData::Ptr result = std::make_shared<FrameInferData>();
-        if(!this->ConsumeData(result)) return;
+        HepuTarget::Ptr target = std::make_shared<HepuTarget>();
+        if(!this->ConsumeData(result,target)) return;
         if(result->Num == 0) return;
         if(!TcpPlugin::getPtr()->Alive()){
             result->uuid = uuid::generate();
@@ -115,6 +116,14 @@ namespace gsd
                 #endif
             });
         }
+
+        //send data to hepu
+        if(config::getPtr()->Hepu)
+        {
+            if(HepuPlugin::getPtr()->Alive()){
+                HepuPlugin::getPtr()->SendTarget(*target);
+            }
+        }
     }
 
     /**
@@ -122,7 +131,7 @@ namespace gsd
      * @param {Ptr&} result
      * @return {*}
      */
-    bool MonitorPlugin::ConsumeData(FrameInferData::Ptr& result){
+    bool MonitorPlugin::ConsumeData(FrameInferData::Ptr& result, HepuTarget::Ptr& target){
         std::shared_ptr<CNStreamInferData> cnstreamInferData = std::make_shared<CNStreamInferData>();
         if(this->monitor == nullptr) return false;
         auto result_data = monitor->ConsumeData(cnstreamInferData);
@@ -157,6 +166,7 @@ namespace gsd
             rapidjson::StringBuffer buffer;
             rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
             writer.StartArray();
+            
             for(auto &obj : cnstreamInferData->Objects)
             {
                 writer.StartObject();
@@ -172,6 +182,31 @@ namespace gsd
             }
             writer.EndArray();
 
+            if(config::getPtr()->Hepu)
+            {
+                int x_center,y_center,w_center,h_center;
+                int dist2mid = 167936;//320*320 + 256*256;
+                for(auto &obj : cnstreamInferData->Objects)
+                {
+                    int x_temp,y_temp;
+                    x_temp = obj.BBox.x * 640;
+                    y_temp = obj.BBox.y * 512;
+                    int dist2mid_temp = pow(x_temp-320,2) + pow(y_temp-256,2);
+                    if(dist2mid_temp <= dist2mid)
+                    {
+                        x_center = x_temp;
+                        y_center = y_temp;
+                        w_center = obj.BBox.w * 640;
+                        h_center = obj.BBox.h * 512;
+                        dist2mid = dist2mid_temp;
+                    }
+                }
+                target->trackingRect.x = x_center;
+                target->trackingRect.y = y_center;
+                target->trackingRect.w = w_center;
+                target->trackingRect.h = h_center;
+            }
+
             // 获取时间
             char ctime[80];
             time_t rawtime;
@@ -186,6 +221,7 @@ namespace gsd
             result->Num = cnstreamInferData->Objects.size();
             result->WarningTime = ctime;
             result->VideoPath = cnstreamInferData->videoPath;
+
             return true;
         }
         return false;

+ 2 - 0
source/UserApp/include/UserApp.hpp

@@ -12,6 +12,7 @@
 #include "ExpelPlugin.hpp"
 #include "MonitorPlugin.hpp"
 #include "AuditPlugin.hpp"
+#include "HepuPlugin.hpp"
 
 using namespace std;
 using namespace toolkit;
@@ -72,6 +73,7 @@ namespace gsd
         ExpelPlugin::Ptr m_ExpelPlugin = nullptr;
         MonitorPlugin::Ptr m_MonitorPlugin = nullptr;
         AuditPlugin::Ptr m_AuditPlugin = nullptr;
+        HepuPlugin::Ptr m_HepuPlugin = nullptr;
         
         Timer::Ptr timer0 = nullptr;
     };

+ 10 - 0
source/UserApp/src/UserApp.cpp

@@ -73,6 +73,13 @@ namespace gsd
             return false;
         }
 
+        // HepuPlugin
+        if(this->m_HepuPlugin == nullptr) m_HepuPlugin = HepuPlugin::getPtr();
+        if(!this->m_HepuPlugin->Init()){
+            ErrorL << "HepuPlugin init failed" << endl;
+            return false;
+        }
+
         // 释放资源
         NoticeCenter::Instance().addListener(0, NOTICE_DESTROY,
             [&](){
@@ -111,6 +118,8 @@ namespace gsd
 
         // HTTP启动任务
         if(this->m_HttpPlugin != nullptr) this->m_HttpPlugin->StartTask();
+
+        if(this->m_HepuPlugin != nullptr) this->m_HepuPlugin->StartTask();
         
         return true;
     }  
@@ -124,6 +133,7 @@ namespace gsd
         if(this->m_MonitorPlugin != nullptr) this->m_MonitorPlugin->Destroy();
         if(this->m_TcpPlugin != nullptr)  this->m_TcpPlugin->Destroy();
         if(this->m_HttpPlugin != nullptr) this->m_HttpPlugin->Destroy();
+        if(this->m_HepuPlugin != nullptr) this->m_HepuPlugin->Destroy();
     }
 
     /**

+ 1 - 1
test/CMakeLists.txt

@@ -70,7 +70,7 @@ include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/httplib/)
 # include_directories(${CNSTREAM_ROOT_DIR}/modules/InfineFilter/include)
 # include_directories(${CNSTREAM_ROOT_DIR}/modules/Monitor/include)
 # include_directories(${CNSTREAM_ROOT_DIR}/modules/TCPClient/include)
-# include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
+include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
 include_directories(${CNSTREAM_ROOT_DIR}/modules/Hepu/include)
 include_directories(${CNSTREAM_ROOT_DIR}/test/TestApp/include)
 include_directories(${CNSTREAM_ROOT_DIR}/framework/core/include)

BIN
test/bin/hepu_test