|
@@ -4,7 +4,7 @@
|
|
|
* @Autor: lishengyin
|
|
|
* @Date: 2021-10-13 09:35:37
|
|
|
* @LastEditors: lishengyin
|
|
|
- * @LastEditTime: 2022-01-13 13:58:03
|
|
|
+ * @LastEditTime: 2022-02-21 08:57:57
|
|
|
*/
|
|
|
#include "inference.h"
|
|
|
|
|
@@ -20,7 +20,7 @@
|
|
|
#define OSD_PROCESS_MODE 0
|
|
|
|
|
|
/* By default, OSD will not display text. To display text, change this to 1 */
|
|
|
-#define OSD_DISPLAY_TEXT 1
|
|
|
+#define OSD_DISPLAY_TEXT 0
|
|
|
|
|
|
/* The muxer output resolution must be set if the input streams will be of
|
|
|
* different resolution. The muxer will scale all the input frames to this
|
|
@@ -67,14 +67,9 @@ namespace MIVA{
|
|
|
DebugL << "Returned, stopping playback" << endl;
|
|
|
// GstState state;
|
|
|
GstStateChangeReturn state_return;
|
|
|
- // gst_element_get_state(this->pipeline,&state,NULL, GST_CLOCK_TIME_NONE);
|
|
|
- // if(state == GST_STATE_PLAYING){
|
|
|
- // DebugL << "pipeline状态设置为暂停" << endl;
|
|
|
- // state_return = gst_element_set_state(this->pipeline, GST_STATE_PAUSED);
|
|
|
- // StateResulit(state_return);
|
|
|
- // }
|
|
|
g_main_loop_quit (this->loop);
|
|
|
state_return = gst_element_set_state(this->pipeline, GST_STATE_NULL);
|
|
|
+
|
|
|
StateResulit(state_return);
|
|
|
DebugL << "Deleting pipeline";
|
|
|
|
|
@@ -85,7 +80,7 @@ namespace MIVA{
|
|
|
|
|
|
this->m_InferInfo = NULL;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @description: 创建实例
|
|
|
* @param {*}
|
|
@@ -108,7 +103,7 @@ namespace MIVA{
|
|
|
// init
|
|
|
this->loop = g_main_loop_new (NULL, FALSE);
|
|
|
// 创建管道
|
|
|
- this->pipeline = gst_pipeline_new("dstest3-pipeline");
|
|
|
+ this->pipeline = gst_pipeline_new("miva-pipeline");
|
|
|
|
|
|
// 创建批处理器
|
|
|
this->streammux = gst_element_factory_make ("nvstreammux", "stream-muxer");
|
|
@@ -145,8 +140,6 @@ namespace MIVA{
|
|
|
this->queue2 = gst_element_factory_make ("queue", "queue2");
|
|
|
this->queue3 = gst_element_factory_make ("queue", "queue3");
|
|
|
this->queue4 = gst_element_factory_make ("queue", "queue4");
|
|
|
- // this->queue5 = gst_element_factory_make ("queue", "queue5");
|
|
|
-
|
|
|
|
|
|
/* Use nvtiler to composite the batched frames into a 2D tiled array based
|
|
|
* on the source of the frames. */
|
|
@@ -157,10 +150,6 @@ namespace MIVA{
|
|
|
|
|
|
this->nvosd = gst_element_factory_make ("nvdsosd", "nv-onscreendisplay");
|
|
|
|
|
|
- // #ifdef PLATFORM_TEGRA
|
|
|
- // this->transform = gst_element_factory_make ("nvegltransform", "nvegl-transform");
|
|
|
- // #endif
|
|
|
-
|
|
|
this->sink = gst_element_factory_make ("fakesink", "nvvideo-renderer");
|
|
|
|
|
|
if (!this->pgie || !this->nvvidconv || !this->nvosd || !this->sink) {
|
|
@@ -168,13 +157,6 @@ namespace MIVA{
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- // #ifdef PLATFORM_TEGRA
|
|
|
- // if(!this->transform) {
|
|
|
- // ErrorL << "One tegra element could not be created. Exiting.";
|
|
|
- // return -1;
|
|
|
- // }
|
|
|
- // #endif
|
|
|
-
|
|
|
g_object_set(G_OBJECT(streammux), "batch-size", g_num_sources, NULL);
|
|
|
|
|
|
g_object_set(G_OBJECT(streammux), "live-source", 1, NULL);
|
|
@@ -204,6 +186,8 @@ namespace MIVA{
|
|
|
g_object_set (G_OBJECT (this->nvosd), "process-mode", OSD_PROCESS_MODE,
|
|
|
"display-text", OSD_DISPLAY_TEXT, NULL);
|
|
|
g_object_set (G_OBJECT (this->nvosd), "display-bbox", 0, NULL);
|
|
|
+ // g_object_set (G_OBJECT (this->nvosd), "display-mask", 0, NULL);
|
|
|
+
|
|
|
g_object_set (G_OBJECT (this->sink), "qos", 0, NULL);
|
|
|
|
|
|
this->bus = gst_pipeline_get_bus (GST_PIPELINE (this->pipeline));
|
|
@@ -218,9 +202,10 @@ namespace MIVA{
|
|
|
ErrorL << "Elements could not be linked. Exiting.";
|
|
|
return -1;
|
|
|
}
|
|
|
+
|
|
|
// this->tiler, this->queue4,
|
|
|
// this->nvosd, this->queue4,
|
|
|
-
|
|
|
+
|
|
|
this->tiler_sink_pad = gst_element_get_static_pad (this->nvvidconv, "src");
|
|
|
gst_pad_add_probe (this->tiler_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
|
|
|
tiler_sink_pad_buffer_probe, NULL, NULL);
|
|
@@ -275,15 +260,16 @@ namespace MIVA{
|
|
|
{
|
|
|
GstStateChangeReturn state_return;
|
|
|
std::vector<DataSource>::iterator iter;
|
|
|
- // gst_element_set_state(this->pipeline, GST_STATE_PAUSED);
|
|
|
+
|
|
|
for (iter = this->m_InferInfo->DataSources.begin(); iter != this->m_InferInfo->DataSources.end(); iter++){
|
|
|
if(iter->source_bin != NULL){
|
|
|
state_return = gst_element_set_state(iter->source_bin, GST_STATE_NULL);
|
|
|
StateResulit(state_return);
|
|
|
}
|
|
|
}
|
|
|
- // state_return = gst_element_set_state(this->streammux, GST_STATE_NULL);
|
|
|
- // StateResulit(state_return);
|
|
|
+ state_return = gst_element_set_state(this->streammux, GST_STATE_NULL);
|
|
|
+ StateResulit(state_return);
|
|
|
+
|
|
|
if(m_recorder != nullptr){
|
|
|
m_recorder->Finish();
|
|
|
}
|
|
@@ -409,7 +395,6 @@ namespace MIVA{
|
|
|
if (obj_meta->class_id == 0) {
|
|
|
NvDsComp_BboxInfo boxInfo;
|
|
|
boxInfo = obj_meta->detector_bbox_info;
|
|
|
-
|
|
|
NvBbox_Coords box_Coord;
|
|
|
box_Coord = boxInfo.org_bbox_coords;
|
|
|
Point p;
|
|
@@ -493,6 +478,7 @@ namespace MIVA{
|
|
|
cv::rectangle(*frame, top_left, bottom_right, color, 3);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if(inferRange.jsonToObject(json)){
|
|
|
if(inferRange.m_points.size() > 0){
|
|
|
for(int i = 0; i < (int)(inferRange.m_points.size()); i++)
|