Explorar el Código

修复程序内存溢出、解决僵尸资源重复堆积加载、进一步缩减推理资源加载速度

lishengyin hace 3 años
padre
commit
3ba0f784a3
Se han modificado 3 ficheros con 27 adiciones y 25 borrados
  1. BIN
      lib/libmodules.so
  2. 24 22
      modules/inference/src/inference.cpp
  3. 3 3
      modules/userApp/src/user_app.cpp

BIN
lib/libmodules.so


+ 24 - 22
modules/inference/src/inference.cpp

@@ -4,7 +4,7 @@
  * @Autor: lishengyin
  * @Date: 2021-10-13 09:35:37
  * @LastEditors: lishengyin
- * @LastEditTime: 2021-10-13 14:51:24
+ * @LastEditTime: 2021-10-14 15:12:36
  */
 #include "inference.h"
 
@@ -265,7 +265,7 @@ namespace MIVA{
         std::vector<DataSource>::iterator iter;
         for (iter = this->m_DataList.begin(); iter != this->m_DataList.end(); iter++){
             if(iter->Play){
-                gst_element_set_state(iter->source_bin, GST_STATE_READY);
+                gst_element_set_state(iter->source_bin, GST_STATE_NULL);
                 iter->Play = false;
             }
             sourceId++;
@@ -334,33 +334,33 @@ namespace MIVA{
                 }
             }
             //画左上角的统计信息
-            display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
-            NvOSD_TextParams *txt_params  = &display_meta->text_params[0];
-            display_meta->num_labels = 1;
-            txt_params->display_text = (char *)g_malloc0 (MAX_DISPLAY_LEN);
+            // display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
+            // NvOSD_TextParams *txt_params  = &display_meta->text_params[0];
+            // display_meta->num_labels = 1;
+            // txt_params->display_text = (char *)g_malloc0 (MAX_DISPLAY_LEN);
 
-            snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Number of people: %d \n", num);
+            // snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Number of people: %d \n", num);
 
             // 推理广播
             NoticeCenter::Instance().emitEvent(NOTICE_INFER,frame_meta->source_id, num);
 
-            txt_params->x_offset = 30;
-            txt_params->y_offset = 30;
+            // txt_params->x_offset = 30;
+            // txt_params->y_offset = 30;
 
-            /* Font , font-color and font-size */
-            txt_params->font_params.font_name = (char *)"Serif";
-            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;
-            txt_params->font_params.font_color.alpha = 1.0;
+            // /* Font , font-color and font-size */
+            // txt_params->font_params.font_name = (char *)"Serif";
+            // 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;
+            // txt_params->font_params.font_color.alpha = 1.0;
 
-            /* Text background color */
-            txt_params->set_bg_clr = 1;
-            txt_params->text_bg_clr.red = 0.0;
-            txt_params->text_bg_clr.green = 0.0;
-            txt_params->text_bg_clr.blue = 0.0;
-            txt_params->text_bg_clr.alpha = 1.0;
+            // /* Text background color */
+            // txt_params->set_bg_clr = 1;
+            // txt_params->text_bg_clr.red = 0.0;
+            // txt_params->text_bg_clr.green = 0.0;
+            // 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);
         }
@@ -509,6 +509,7 @@ namespace MIVA{
             gst_object_unref (sinkpad);
         }
     }
+
     /**
      * @description: 创建数据源element
      * @param {guint} index
@@ -530,6 +531,7 @@ namespace MIVA{
             G_CALLBACK (cb_newpad), &g_source_id_list[index]);
         g_signal_connect (G_OBJECT (bin), "child-added",
             G_CALLBACK (decodebin_child_added), &g_source_id_list[index]);
+        
         g_source_enabled[index] = TRUE;
 
         return bin;

+ 3 - 3
modules/userApp/src/user_app.cpp

@@ -4,7 +4,7 @@
  * @Autor: lishengyin
  * @Date: 2021-10-13 09:35:42
  * @LastEditors: lishengyin
- * @LastEditTime: 2021-10-13 10:33:53
+ * @LastEditTime: 2021-10-14 08:45:43
  */
 #include "user_app.h"
 
@@ -207,8 +207,8 @@ namespace MIVA
 
     /**
      * @description: 监听推理广播
-     * @param {int} Source_id
-     * @param {int} num
+     * @param {int} Source_id 数据源ID
+     * @param {int} num 推理结果
      * @return {*}
      * @author: lishengyin
      */