Browse Source

30路数据测试

lishengyin 3 years ago
parent
commit
056309d21e

+ 1 - 0
modules/inference/include/inference.h

@@ -59,6 +59,7 @@ namespace MIVA{
         int32_t Init(std::list<DataSource> DataList);
         void Destory();
         void StartTask();
+        void PauseTask();
     private:
         // static 
         static GstPadProbeReturn tiler_src_pad_buffer_probe(GstPad * pad, GstPadProbeInfo * info, gpointer u_data);

+ 11 - 10
modules/inference/src/inference.cpp

@@ -43,7 +43,7 @@ namespace MIVA{
     }
     Inference::Inference()
     {
-
+        
     }
     Inference::~Inference()
     {
@@ -173,7 +173,6 @@ namespace MIVA{
         this->bus_watch_id = gst_bus_add_watch (this->bus, bus_call, this->loop);
         gst_object_unref (this->bus);
 
-
         gst_bin_add_many (GST_BIN (this->pipeline), this->queue1, this->pgie, this->queue2, this->tiler, this->queue3,
             this->nvvidconv, this->queue4, this->nvosd, this->queue5, this->transform, this->sink, NULL);
             /* we link the elements together
@@ -201,9 +200,14 @@ namespace MIVA{
         InfoL << "Now palying";
         gst_element_set_state(this->pipeline, GST_STATE_PLAYING);
         // 挂起任务
-        // g_main_loop_run(this->loop);
+        g_main_loop_run(this->loop);
+    }
+    // 暂停任务
+    void Inference::PauseTask()
+    {
+        InfoL << "Now stop";
+        gst_element_set_state(this->pipeline, GST_STATE_PAUSED);
     }
-
     // 销毁对象
     void Inference::Destory()
     {
@@ -227,14 +231,11 @@ namespace MIVA{
         NvDsMetaList * l_frame = NULL;
         NvDsMetaList * l_obj = NULL;
         NvDsDisplayMeta *display_meta = NULL; 
-
-        int num = 0;
         
-
         for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;l_frame = l_frame->next) //从批量中获取某一帧图
         {
             NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
-
+            int num = 0;
             for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;l_obj = l_obj->next) 
             {
                 obj_meta = (NvDsObjectMeta *) (l_obj->data);
@@ -259,7 +260,7 @@ namespace MIVA{
 
             /* Font , font-color and font-size */
             txt_params->font_params.font_name = (char *)"Serif";
-            txt_params->font_params.font_size = 30;
+            txt_params->font_params.font_size = 10;
             txt_params->font_params.font_color.red = 1.0;
             txt_params->font_params.font_color.green = 1.0;
             txt_params->font_params.font_color.blue = 1.0;
@@ -272,7 +273,7 @@ namespace MIVA{
             txt_params->text_bg_clr.blue = 0.0;
             txt_params->text_bg_clr.alpha = 1.0;
 
-            nvds_add_display_meta_to_frame(frame_meta, display_meta);
+            // nvds_add_display_meta_to_frame(frame_meta, display_meta);
         }
         return GST_PAD_PROBE_OK;
     }

+ 1 - 0
modules/userApp/include/user_app.h

@@ -90,6 +90,7 @@ namespace MIVA
         std::list<DataSource> DataList;
         Timer::Ptr m_timer0;
         Timer::Ptr m_timer1;
+        Timer::Ptr m_timer2;
 
     private:
         void ListenInfer(int Source_id, int num);

+ 22 - 8
modules/userApp/src/user_app.cpp

@@ -73,10 +73,13 @@ namespace MIVA
         // UDP绑定端口
         this->m_udpClient = Socket::createSocket();
         this->m_udpClient->bindUdpSock(this->PIS_port);
-
-        // 查询需要播放的流
+        
         vector<vector<string>> sqlRet;
-        SqlWriter sqlSelect("SELECT Id,Uri FROM MIVA_DB.`DataSources` WHERE Play = 1 and Delete = 0");
+        // 清洗旧数据
+        SqlWriter sqlUpdata("UPDATE MIVA_DB.DataSources SET Num=0");
+        sqlUpdata << sqlRet;
+        // 查询需要播放的流
+        SqlWriter sqlSelect("SELECT Id,Uri FROM MIVA_DB.`DataSources` WHERE Play = 1 and Del = 0");
         sqlSelect << sqlRet;
         if(!sqlRet.empty()){
             for(auto &line : sqlRet){
@@ -124,7 +127,7 @@ namespace MIVA
     void UserApp::StartTask()
     {
         // 创建推理线程池
-        ThreadPool poolInfer(1,ThreadPool::PRIORITY_HIGHEST, false);
+        ThreadPool poolInfer(4,ThreadPool::PRIORITY_HIGHEST, false);
 
         // 挂起任务一
         poolInfer.async([&](){
@@ -158,11 +161,22 @@ namespace MIVA
     // 监听推理广播
     void UserApp::ListenInfer(int Source_id, int num)
     {   
+        static int ret = 0;
+        if(ret == 0){
+            this->m_timer2 = std::make_shared<Timer>(3.0f,[&](){
+                // 暂停任务
+                this->m_Infer->PauseTask();
+                return false;
+            }, nullptr);
+            ret++;
+        }
         char ctime[80];
+        vector<vector<std::string>> sqlRet;
         getDataTime(ctime);
-        // 异步更新
-        SqlWriter updataSql("UPDATE MIVA_DB.DataSources SET Num = '?' DataTime = '?' WHERE Id = '?';");
-        updataSql << num << ctime << Source_id << endl;
+
+        Source_id +=1;
+        SqlWriter updataSql("UPDATE MIVA_DB.DataSources SET Num = '?',DataTime = '?' WHERE Id = '?';");
+        updataSql << num << ctime << Source_id << sqlRet;
     }   
 
     // 连接Netty
@@ -213,7 +227,7 @@ namespace MIVA
     void UserApp::ListenNettyData(const Buffer::Ptr &pBuf)
     {
         // 对Netty端的接口
-
+        
 
 
     }

+ 3 - 3
source/bin/config_infer_primary_yoloV5.txt

@@ -42,12 +42,12 @@ net-scale-factor=0.0039215697906911373
 model-color-format=0
 # custom-network-config=yolov3-tiny.cfg
 # model-file=yolov3-tiny.weights
-model-engine-file=yolov5s.engine
+model-engine-file=./INT8/yolov5s.engine
 labelfile-path=labels.txt
 process-mode=1
-batch-size=2
+batch-size=12
 ## 0=FP32, 1=INT8, 2=FP16 mode
-network-mode=1
+network-mode=2
 num-detected-classes=1
 gie-unique-id=1
 network-type=0