add nvtracker and some nvinfer in deepstream_test3_app but only one nvinfer work

i have a problem, i am add some nvinfer in the sample deepstream_test3_apponly work t the pgie, label in every object only display vehicule or person but not the others nvinfer

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

if (!pipeline || !streammux) {
g_printerr (“One element could not be created. Exiting.\n”);
return -1;
gst_bin_add (GST_BIN (pipeline), streammux);

for (i = 0; i < num_sources; i++) {
GstPad *sinkpad, *srcpad;
gchar pad_name[16] = { };
GstElement *source_bin = create_source_bin (i, argv[i + 1]);

if (!source_bin) {
  g_printerr ("Failed to create source bin. Exiting.\n");
  return -1;

gst_bin_add (GST_BIN (pipeline), source_bin);

g_snprintf (pad_name, 15, "sink_%u", i);
sinkpad = gst_element_get_request_pad (streammux, pad_name);
if (!sinkpad) {
  g_printerr ("Streammux request sink pad failed. Exiting.\n");
  return -1;

srcpad = gst_element_get_static_pad (source_bin, "src");
if (!srcpad) {
  g_printerr ("Failed to get src pad of source bin. Exiting.\n");
  return -1;

if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) {
  g_printerr ("Failed to link source bin to stream muxer. Exiting.\n");
  return -1;

gst_object_unref (srcpad);
gst_object_unref (sinkpad);

/* Use nvinfer to run inferencing on decoder’s output,

  • behaviour of inferencing is set through config file /
    pgie = gst_element_factory_make (“nvinfer”, “primary-nvinference-engine”);
    We need to have a tracker to track the identified objects */
    nvtracker = gst_element_factory_make (“nvtracker”, “tracker”);

/* We need three secondary gies so lets create 3 more instances of
nvinfer */
sgie1 = gst_element_factory_make (“nvinfer”, “secondary1-nvinference-engine”);

sgie2 = gst_element_factory_make (“nvinfer”, “secondary2-nvinference-engine”);

sgie3 = gst_element_factory_make (“nvinfer”, “secondary3-nvinference-engine”);

/* Use nvtiler to composite the batched frames into a 2D tiled array based

  • on the source of the frames. */
    tiler = gst_element_factory_make (“nvmultistreamtiler”, “nvtiler”);

/* Use convertor to convert from NV12 to RGBA as required by nvosd */
nvvidconv = gst_element_factory_make (“nvvidconv”, “nvvideo-converter”);

/* Create OSD to draw on the converted RGBA buffer /
nvosd = gst_element_factory_make (“nvosd”, “nv-onscreendisplay”);
Finally render the osd output */
sink = gst_element_factory_make (“nveglglessink”, “nvvideo-renderer”);

if (!pgie || !nvtracker ||
!sgie1 || !sgie2 || !sgie3 || !tiler || !nvvidconv || !nvosd || !sink) {
g_printerr (“One element could not be created. Exiting.\n”);
return -1;

g_object_set (G_OBJECT (streammux), “width”, MUXER_OUTPUT_WIDTH, “height”,
MUXER_OUTPUT_HEIGHT, “batch-size”, num_sources,
“batched-push-timeout”, MUXER_BATCH_TIMEOUT_USEC, NULL);

/* we set the input filename to the source element
g_object_set (G_OBJECT (source), “location”, argv[1], NULL);

/* Set all the necessary properties of the nvinfer element,

  • the necessary ones are : */
    g_object_set (G_OBJECT (pgie), “config-file-path”, PGIE_CONFIG_FILE, NULL);
    g_object_set (G_OBJECT (sgie1), “config-file-path”, SGIE1_CONFIG_FILE, NULL);
    g_object_set (G_OBJECT (sgie2), “config-file-path”, SGIE2_CONFIG_FILE, NULL);
    g_object_set (G_OBJECT (sgie3), “config-file-path”, SGIE3_CONFIG_FILE, NULL);

/* Override the batch-size set in the config file with the number of sources. */
g_object_get (G_OBJECT (pgie), “batch-size”, &pgie_batch_size, NULL);
if (pgie_batch_size != num_sources) {
(“WARNING: Overriding infer-config batch-size (%d) with number of sources (%d)\n”,
pgie_batch_size, num_sources);
g_object_set (G_OBJECT (pgie), “batch-size”, num_sources, NULL);

tiler_rows = (guint) sqrt (num_sources);
tiler_columns = (guint) ceil (1.0 * num_sources / tiler_rows);
/* we set the tiler properties here /
g_object_set (G_OBJECT (tiler), “rows”, tiler_rows, “columns”, tiler_columns,
we set the osd properties here */
g_object_set (G_OBJECT (nvosd), “font-size”, 15, NULL);

/* we add a message handler */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);

/* Set up the pipeline /
we add all elements into the pipeline /
decoder | pgie1 | nvtracker | sgie1 | sgie2 | sgie3 | etc… */
gst_bin_add_many (GST_BIN (pipeline), pgie, nvtracker, sgie1, sgie2, sgie3,tiler,
nvvidconv, nvosd, sink, NULL);

if (!gst_element_link_many (streammux, pgie,nvtracker, sgie1,
sgie2, sgie3,tiler,nvvidconv, nvosd, tee, NULL)) {
g_printerr (“Elements could not be linked. Exiting.\n”);
return -1;

tiler_src_pad = gst_element_get_static_pad (nvtracker, “src”);
//tiler_src_pad = gst_element_get_static_pad (nvosd, “sink”);
if (!tiler_src_pad)
g_print (“Unable to get src pad\n”);
gst_pad_add_probe (tiler_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
tiler_src_pad_buffer_probe, NULL, NULL);

Hi maserrot
Can you upload all you code?
You can also refer to test2 which has nvtracker and multiple models.