Explorar el Código

优化Init资源分配,加快从拉流到识别的速度

lishengyin hace 3 años
padre
commit
669f18c917

BIN
lib/libmodules.so


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

@@ -58,9 +58,9 @@ namespace MIVA{
     public:
         int32_t Init(std::vector<DataSource> DataList);
         void Destory();
+        void ReadyTask();
         void StartTask();
         void PauseTask();
-        void RestartTask();
     private:
         // static 
         static GstPadProbeReturn tiler_src_pad_buffer_probe(GstPad * pad, GstPadProbeInfo * info, gpointer u_data);

+ 6 - 9
modules/inference/src/inference.cpp

@@ -193,14 +193,17 @@ namespace MIVA{
 
         return OK;
     }
-
+    void Inference::ReadyTask()
+    {
+         InfoL << "Now ReadyTask";
+         gst_element_set_state(this->pipeline, GST_STATE_READY);
+         g_main_loop_run(this->loop);
+    }
     // 启动任务
     void Inference::StartTask()
     {
         InfoL << "Now palying";
         gst_element_set_state(this->pipeline, GST_STATE_PLAYING);
-        // 挂起任务
-        g_main_loop_run(this->loop);
     }
     // 暂停任务
     void Inference::PauseTask()
@@ -208,12 +211,6 @@ namespace MIVA{
         InfoL << "Now Pause";
         gst_element_set_state(this->pipeline, GST_STATE_PAUSED);
     }
-    // 重启程序
-    void Inference::RestartTask()
-    {
-        InfoL << "Now start";
-        gst_element_set_state(this->pipeline, GST_STATE_PLAYING);
-    }
     // 销毁对象
     void Inference::Destory()
     {

+ 4 - 12
modules/userApp/src/user_app.cpp

@@ -134,9 +134,8 @@ namespace MIVA
     void UserApp::StartTask()
     {
         // 挂起任务一
-
         poolInfer.async([&](){
-            if(this->m_Infer != NULL) m_Infer->StartTask();
+            if(this->m_Infer != NULL) m_Infer->ReadyTask();
         });
 
         // 挂起函数回调
@@ -158,6 +157,7 @@ namespace MIVA
             return true;
         }, nullptr);
 
+        poolInfer.start();
         InfoL << "Task started successfully!";
     }
 
@@ -238,7 +238,6 @@ namespace MIVA
         vector<vector<std::string>> sqlRet;
         // 接受到PIS发送的数据
         PIDSServerResultMsg serverResultMag;
-        InfoL << "wwwww";
         // 反序列化
         if(serverResultMag.Deserialization((uint8_t *)(buf->data()), buf->size()) == OK)
         {
@@ -280,15 +279,8 @@ namespace MIVA
     //监听关门信号
     void UserApp::ListenClosed()
     {
-        static int num = 0;
-        if(num == 0){
-            // 创建推理线程池
-            poolInfer.start();
-            num++;
-        }else{
-            if(this->m_Infer != NULL) m_Infer->RestartTask();
-            this->play = true;
-        }
+        if(this->m_Infer != NULL) m_Infer->StartTask();
+        this->play = true;
     }
     // 监听推理数据
     void UserApp::ListenInferData()

BIN
source/bin/main