Problems with deepstream segmentation algorithm

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)

• Issue Type( questions, new requirements, bugs)
The deepstream algorithm is slow to display both the segmentation result and the original input image, about a frame.When the segmentation is displayed individually, it’s very fast, about 50 frames。

You mean when you add tee to display the origin video, it’s slow, like tee->nvvideoconvert->display? Could you attach your minimized code to us?
Also, could you update your deepstream to the latest version 6.2?

code:The function of the code is to read the local image, and display (multiple paths)

int main ()
guint bus_watch_id;

GstElement *pipeline,*bin,*parser,*decoder, *streammux, *nvvidconv, *transform,*sink,*filter2,*convert3,*tiler,*nvdslogger, *seg,*nvsegvisual,*tee, *nvvidconv1,*sink1 ;
GMainLoop *loop = NULL;
GstBus *bus;
CustomData data1;

gst_init (NULL, NULL);
loop = g_main_loop_new (NULL, FALSE);
pipeline = gst_pipeline_new (“dstensor-pipeline”);

bin=gst_bin_new (“new-bin”);
data1.source = gst_element_factory_make (“multifilesrc”, “file-source0”);
parser = gst_element_factory_make (“jpegparse”, “jpeg-parser0”);
decoder = gst_element_factory_make (“nvv4l2decoder”, “nvv4l2-decoder0”);


streammux = gst_element_factory_make (“nvstreammux”, “stream-muxer”);

nvdslogger = gst_element_factory_make (“nvdslogger”, “nvdslogger”);

nvvidconv = gst_element_factory_make (“nvvideoconvert”, “nvvideo-converter”);
sink = gst_element_factory_make (“nveglglessink”, “nvvideo-renderer”);

gst_bin_add_many (GST_BIN (bin),data1.source, parser, decoder, NULL);

GstPad *source_pad = gst_element_get_static_pad(decoder, “src”);

tee = gst_element_factory_make(“tee”, “tee”);

nvvidconv1 = gst_element_factory_make (“nvvideoconvert”, “nvvideo-converter1”);
sink1 = gst_element_factory_make (“nveglglessink”, “nvvideo-renderer1”);

/// g_object_set (G_OBJECT (tiler), “rows”, 1, “columns”, 2,
/// “width”, 1024, “height”,1024, NULL);

if (!gst_element_link_many (data1.source, parser, decoder, NULL))
g_printerr (“Elements could not be linked: 0. Exiting.\n”);
return -1;

gst_bin_add_many (GST_BIN (pipeline),bin,streammux,tee,
nvvidconv, sink, nvvidconv1, sink1, NULL);

if (!pipeline||!data1.source || !parser || !decoder||!streammux || !nvvidconv || !sink ) {
g_printerr (“One element could not be created. Exiting.\n”);
return -1;

g_object_set(G_OBJECT(data1.source), “location”,“/home/cui/Desktop/new_image/image_%d.jpeg”, NULL);

g_object_set(G_OBJECT( streammux),“width”,1056,“height”,256, “batch-size”, 1, “batched-push-timeout”, MUXER_BATCH_TIMEOUT_USEC,NULL);
g_object_set (G_OBJECT(sink), “sync”, FALSE, NULL);

g_object_set (G_OBJECT (sink), “qos”, 0, NULL);

GstPad *sinkpad,*srcpad;
gchar pad_name_src[16] = “src”;
gchar pad_name_sink[16] = “sink_0”;

srcpad = gst_element_get_static_pad (bin, pad_name_src);
if (!srcpad) {
g_printerr (“Decoder request src pad failed. Exiting.\n”);
return -1;

sinkpad = gst_element_get_request_pad (streammux, pad_name_sink);
if (!sinkpad) {
g_printerr (“Streammux request sink pad failed. Exiting.\n”);
return -1;

if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) {
g_printerr (“Failed to link decoder to stream muxer1. Exiting.\n”);
return -1;


if (!gst_element_link_many (streammux, tee, NULL)) {
g_printerr (“Elements could not be linked: 1. Exiting.\n”);
return -1;

gchar tee_src[16] = “src_0”;
gchar tee_src1[16] = “src_1”;
GstPad *teepad,*teepad1;
teepad = gst_element_get_request_pad (tee, tee_src);
teepad1 = gst_element_get_request_pad (tee, tee_src1);

GstPad *segpad;
segpad = gst_element_get_static_pad (nvvidconv, “sink”);

GstPad *nvvidpad;
nvvidpad = gst_element_get_static_pad (nvvidconv1, “sink”);

if (gst_pad_link (teepad,segpad) != GST_PAD_LINK_OK) {
g_printerr (“Failed to link decoder to teepad,segpad. Exiting.\n”);
return -1;

if (gst_pad_link (teepad1, nvvidpad) != GST_PAD_LINK_OK) {
g_printerr (“Failed to link decoder to teepad1, nvvidpad. Exiting.\n”);
return -1;

if (!gst_element_link_many (nvvidconv, sink, NULL)) {
g_printerr (“Elements could not be linked: 2. Exiting.\n”);
return -1;

if (!gst_element_link_many (nvvidconv1, sink1, NULL)) {
g_printerr (“Elements could not be linked: 3. Exiting.\n”);
return -1;


//if (!gst_element_link_many (streammux, seg,nvsegvisual,nvdslogger,nvvidconv, sink, NULL)) {
// g_printerr (“Elements could not be linked: 1. Exiting.\n”);
// return -1;
// }

//GstPad *tiler_src_pad =gst_element_get_static_pad(data1.source,“src”);
//gst_pad_add_probe (tiler_src_pad, GST_PAD_PROBE_TYPE_BUFFER,tiler_src_pad_buffer_probe, &data1, NULL);

//GstPad *tiler_src_pad_s =gst_element_get_static_pad (sink,“sink”);
//gst_pad_add_probe (tiler_src_pad_s, GST_PAD_PROBE_TYPE_BUFFER,tiler_src_pad_buffer_probe1, NULL, NULL);

//GstPad *tiler_src_pad_c =gst_element_get_static_pad (sink,“sink”);
//gst_pad_add_probe (tiler_src_pad_c, GST_PAD_PROBE_TYPE_BUFFER,tiler_src_pad_buffer_probe1, NULL, NULL);

GST_DEBUG_GRAPH_SHOW_ALL, “pipeline-playing”);

gst_element_set_state (pipeline, GST_STATE_PLAYING);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);

/* Iterate */
g_print (“Running…\n”);
g_main_loop_run (loop);

/* Out of the main loop, clean up nicely */
g_print (“Returned, stopping playback\n”);
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print (“Deleting pipeline\n”);
gst_object_unref (GST_OBJECT (pipeline));
g_source_remove (bus_watch_id);
g_main_loop_unref (loop);

return 0;

It requires a lot of resources with 2 eglsink rendering video after tee plugin. Is your needs to display both the segmentation result and the original input image in the same video?

The problem has been solved,

Glad to hear that. Could you share your solution for future reference of other customers?

The two sinks are set to:
g_object_set (G_OBJECT(sink), “sync”, FALSE, NULL);
g_object_set (G_OBJECT(sink1), “sync”, FALSE, NULL);

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.