Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) : GPU
• DeepStream Version : 6.1
if (!gst_element_link_many(streammux, queue1, pgie, queue2, tracker, queue3, sgie1, queue4, sgie2, queue5, nvdslogger,
queue6, nvvidconv, queue7, nvosd, queue8, sink, NULL));
{
g_printerr("Elements could not be linked. Exiting.\n");
return -1;
}
Can somebody please help where I’m wrong in linking the elements as when I run the application it shows
Elements could not be linked. Exiting
I’m trying to perform ANPR on “nvinfer” not in “nvinferserver”. Also I’m not using titron.
Below is the code for elements creation
/* Standard GStreamer initialization */
gst_init(&argc, &argv);
loop = g_main_loop_new(NULL, FALSE);
/* Create gstreamer elements */
/* Create Pipeline element that will form a connection of other elements */
pipeline = gst_pipeline_new("anpr-pipeline");
/* Create nvstreammux instance to form batches from one or more sources. */
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);
GList *src_list = NULL;
if (g_str_has_suffix(argv[1], ".yml") || g_str_has_suffix(argv[1], ".yaml"))
{
nvds_parse_source_list(&src_list, argv[1], "source-list");
GList *temp = src_list;
while (temp)
{
num_sources++;
temp = temp->next;
}
g_list_free(temp);
}
else
{
num_sources = argc - 1;
}
for (i = 0; i < num_sources; i++)
{
GstPad *sinkpad, *srcpad;
gchar pad_name[16] = {};
GstElement *source_bin = NULL;
if (g_str_has_suffix(argv[1], ".yml") || g_str_has_suffix(argv[1], ".yaml"))
{
g_print("Now playing : %s\n", (char *)(src_list)->data);
source_bin = create_source_bin(i, (char *)(src_list)->data);
}
else
{
source_bin = create_source_bin(i, argv[i + 1]);
}
if (!source_bin)
{
g_printerr("Failed to create source bin. Exiting.\n");
return -1;
}
cout << i << endl;
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);
if (g_str_has_suffix(argv[1], ".yml") || g_str_has_suffix(argv[1], ".yaml"))
{
src_list = src_list->next;
cout << "src_list: "<<src_list << endl;
}
}
if (g_str_has_suffix(argv[1], ".yml") || g_str_has_suffix(argv[1], ".yaml"))
{
g_list_free(src_list);
}
/* Use nvinfer to infer on batched frame. */
pgie = gst_element_factory_make("nvinfer", "primary-nvinference-engine");
sgie1 = gst_element_factory_make("nvinfer","secondary-infer-engine1");
sgie2 = gst_element_factory_make("nvinfer","secondary-infer-engine2");
tracker = gst_element_factory_make("nvtracker", "nvtracker");
/* Add queue elements between every two elements */
queue1 = gst_element_factory_make("queue", "queue1");
queue2 = gst_element_factory_make("queue", "queue2");
queue3 = gst_element_factory_make("queue", "queue3");
queue4 = gst_element_factory_make("queue", "queue4");
queue5 = gst_element_factory_make("queue", "queue5");
queue6 = gst_element_factory_make("queue", "queue6");
queue7 = gst_element_factory_make("queue", "queue7");
queue8 = gst_element_factory_make("queue", "queue8");
/* Use nvdslogger for perf measurement. */
nvdslogger = gst_element_factory_make("nvdslogger", "nvdslogger");
/* 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("nvvideoconvert", "nvvideo-converter");
/* Create OSD to draw on the converted RGBA buffer */
nvosd = gst_element_factory_make("nvdsosd", "nv-onscreendisplay");
if (PERF_MODE)
{
sink = gst_element_factory_make("fakesink", "nvvideo-renderer");
}
else
{
/* Finally render the osd output */
// if (prop.integrated)
// {
// transform = gst_element_factory_make("nvegltransform", "nvegl-transform");
// if (!transform)
// {
// g_printerr("One tegra element could not be created. Exiting.\n");
// return -1;
// }
// }
sink = gst_element_factory_make("fakesink", "nvvideo-renderer");
}
// if (!pgie || !nvdslogger || !tiler || !nvvidconv || !nvosd || !sink)
// {
// g_printerr("One element could not be created. Exiting.\n");
// return -1;
// }
if (!pgie || !sgie1 || !tracker || !sgie2 || !nvdslogger || !nvvidconv || !nvosd || !sink)
{
g_printerr("One element could not be created. Exiting.\n");
return -1;
}
if (g_str_has_suffix(argv[1], ".yml") || g_str_has_suffix(argv[1], ".yaml"))
{
nvds_parse_streammux(streammux, argv[1], "streammux");
nvds_parse_tracker(tracker, argv[1], "tracker");
// g_object_set(G_OBJECT(pgie),
// "config-file-path", "./models/door_pgie_config.yml", NULL);
// g_object_get(G_OBJECT(pgie), "batch-size", &pgie_batch_size, NULL);
nvds_parse_gie(pgie, argv[1], "primary-gie");
nvds_parse_gie(sgie1, argv[1], "secondary-gie-0");
nvds_parse_gie(sgie2, argv[1], "secondary-gie-1");
if (pgie_batch_size != num_sources)
{
g_printerr("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);
}
nvds_parse_osd(nvosd, argv[1], "osd");
// tiler_rows = (guint)sqrt(num_sources);
// tiler_columns = (guint)ceil(1.0 * num_sources / tiler_rows);
// g_object_set(G_OBJECT(tiler), "rows", tiler_rows, "columns", tiler_columns, NULL);
// nvds_parse_tiler(tiler, argv[1], "tiler");
// nvds_parse_egl_sink(sink, argv[1], "sink");
}
else
{
g_object_set(G_OBJECT(streammux), "batch-size", num_sources, NULL);
g_object_set(G_OBJECT(streammux), "width", MUXER_OUTPUT_WIDTH, "height",
MUXER_OUTPUT_HEIGHT,
"batched-push-timeout", MUXER_BATCH_TIMEOUT_USEC, NULL);
/* Configure the nvinfer element using the nvinfer config file. */
g_object_set(G_OBJECT(pgie),
"config-file-path", "./models/door_pgie_config.txt", 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)
{
g_printerr("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,
// "width", TILED_OUTPUT_WIDTH, "height", TILED_OUTPUT_HEIGHT, NULL);
// g_object_set(G_OBJECT(nvosd), "process-mode", OSD_PROCESS_MODE,
// "display-text", OSD_DISPLAY_TEXT, NULL);
g_object_set(G_OBJECT(sink), "qos", 0, NULL);
}