Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU)
orin
• DeepStream Version
6.1
• JetPack Version (valid for Jetson only)
35.1.0
• TensorRT Version
8.5
• Issue Type( questions, new requirements, bugs)
Use DeepStream to read a local JPEG image and display only the first image locally。
the code is ::
int main ()
{
guint bus_watch_id;
GstElement *pipeline,*bin,*parser,*decoder, *streammux, *nvvidconv, *transform,*sink,*filter2,*convert3,*tiler,*nvdslogger, *seg,*nvsegvisual,*tee, *nvvidconv1,*sink1 ,*nvinfer,*nvosd;
GMainLoop *loop = NULL;
GstBus *bus;
CustomData data1;
gst_init (NULL, NULL);
loop = g_main_loop_new (NULL, FALSE);
pipeline = gst_pipeline_new (“dstensor-pipeline”);
GstElement *queue1, *queue2, *queue3;
queue1 = gst_element_factory_make (“queue”, “queue1”);
queue2 = gst_element_factory_make (“queue”, “queue2”);
queue3 = gst_element_factory_make (“queue”, “queue3”);
////—0
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”);
////—1
streammux = gst_element_factory_make (“nvstreammux”, “stream-muxer”);
nvdslogger = gst_element_factory_make (“nvdslogger”, “nvdslogger”);
transform = gst_element_factory_make(“nvegltransform”, “transform”);
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”);
gst_element_add_pad(bin,gst_ghost_pad_new(“src”,source_pad));
seg = gst_element_factory_make (“nvinfer”, “primary-nvinference-engine”);
g_object_set (G_OBJECT (seg),
“config-file-path”, “hdmapnet.txt”, NULL);
nvsegvisual = gst_element_factory_make (“nvsegvisual”, “nvsegvisual”);
g_object_set (G_OBJECT (nvsegvisual), “batch-size”, 1, NULL);
g_object_set (G_OBJECT (nvsegvisual), “width”, 800, NULL);
g_object_set (G_OBJECT (nvsegvisual), “height”, 400, NULL);
nvosd = gst_element_factory_make (“nvdsosd”, “nv-onscreendisplay”);
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,queue1,nvdslogger,queue2,queue3,
nvvidconv, transform, sink,NULL);
if (!pipeline||!data1.source || !parser || !decoder||!streammux || !nvvidconv ||!transform ) {
g_printerr (“One element could not be created. Exiting.\n”);
return -1;
}
g_object_set(G_OBJECT(data1.source), “location”,“/home/titan/detetct_image/image_%d.jpeg”, NULL);
g_object_set(G_OBJECT( streammux),“width”,1024,“height”,1024, “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,queue1,nvdslogger,queue2,queue3,nvvidconv,transform, sink,NULL)) {
g_printerr (“Elements could not be linked: 2. 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,seg_src_pad_buffer_probe, &data1, NULL); //模型推理的输出
GstPad *tiler_src_pad_s =gst_element_get_static_pad (streammux,“src”);
gst_pad_add_probe (tiler_src_pad_s, GST_PAD_PROBE_TYPE_BUFFER,tile_sink_pad_buffer_probe, NULL, NULL);
//GstPad *tiler_src_pad_s =gst_element_get_static_pad ( nvosd,“sink”);
//gst_pad_add_probe (tiler_src_pad_s, GST_PAD_PROBE_TYPE_BUFFER,nvinfer_src_pad_buffer_probe1, NULL, NULL); //修改了图像大小
//GstPad *tiler_src_pad_c =gst_element_get_static_pad (nvdslogger,“sink”);
//gst_pad_add_probe (tiler_src_pad_c, GST_PAD_PROBE_TYPE_BUFFER,nvinfer_src_pad_buffer_probe1, NULL, NULL);
GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN (pipeline),
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;
}