How to insert custom text on screen by gst-dsexample

I found it hard to modify the code. I want to add text such as “Hello word” on screen by gst-dsexample. I modify the code of “::attach_metadata_full_frame” in gst-dsexample. as below:

static void
attach_metadata_full_frame (GstDsExample * dsexample, NvDsFrameMeta *frame_meta,
gdouble scale_ratio, DsExampleOutput * output, guint batch_id)
NvDsBatchMeta *batch_meta = frame_meta->base_meta.batch_meta;
NvDsObjectMeta *object_meta = NULL;
NvDsDisplayMeta *display_meta = NULL;

GST_DEBUG_OBJECT (dsexample, “Attaching metadata %d\n”, output->numObjects);

display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
NvOSD_LineParams *line_params = display_meta->line_params;
NvOSD_TextParams *txt_params = display_meta->text_params;
display_meta->num_labels = 1;
char SOME_LENGTH = (char)“test string”;
txt_params->display_text = (char *) g_malloc(SOME_LENGTH);
txt_params->x_offset = 100;
txt_params->y_offset = 120;
Font , font-color and font-size /
txt_params->font_params.font_name = (char
txt_params->font_params.font_size = 10;
txt_params-> = 0.0;
txt_params-> = 0.0;
txt_params-> = 0.0;
txt_params->font_params.font_color.alpha = 1.0;

/* Text background color */
txt_params->set_bg_clr = 1;
txt_params-> = 1.0;
txt_params-> = 1.0;
txt_params-> = 1.0;
txt_params->text_bg_clr.alpha = 1.0;
display_meta->num_lines = 2;
line_params[0].x1 = 30;
line_params[0].y1 = 50;
line_params[0].x2 = 150;
line_params[0].y2 = 150;
line_params[0].line_width = 2;
line_params[0].line_color = (NvOSD_ColorParams){1.0, 0.0, 0.0, 0.5};
line_params[1].x1 = 50;
line_params[1].y1 = 110;
line_params[1].x2 = 150;
line_params[1].y2 = 150;
line_params[1].line_width = 2;
line_params[1].line_color = (NvOSD_ColorParams){1.0, 0.0, 0.0, 0.5};
nvds_add_display_meta_to_frame (frame_meta, display_meta);
frame_meta->bInferDone = TRUE;

The lines can be shown, however, the text flashes with a messy code. Here just leave a white background.

Please kindly help me. Thank you very much

char myword= (char)“test string”;
txt_params->display_text = (char *) g_malloc(1);
offset = snprintf(txt_params->display_text, 15, myword);

I get it. But I don’t know if right or wrong.

Can you share your pipeline? Where did you put the dsexample plugin in your pipeline?

Thank you Fiona.Chen.
My pipline like this.

I hope add My preprocessor after Decoder. The preprocessor is used to make the video more clearly. I am learning write a plugin to do that based on gst-dexample.
However, I don’t how to add my plugin.
I check the two file “deepstream_app.c” and “deepstream_app_main.c”.
I have the following question:
(1) If right or wrong that I add my plugin at :: create_pipeline in “deepstream_app.c”?
(2) Is the command “gst_bin_add”?
(3) How can I make the order of the plugin? Because I can not find the decoder plugin at here.
(4) Is there anything that I need to modify? such as in destroy_pipline?

Thank you very much

If you are referring to deeptream-app sample(DeepStream Reference Application - deepstream-app — DeepStream DeepStream Version: 5.0 documentation), dsexample has already been supported by it. You don’t need to add it by yourself.

The related code is under /opt/nvidia/deepstream/deepstream-5.0/sources/apps/apps-common/src/deepstream_dsexample.c and /opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample-apps/deepstream-app/deepstream_app.c.

Seems you know little about gstreamer, can you learn basic knowledge of gstreamer DeepStream is based on gstreamer. It is a must to know how to read and understand the pipeline with gstreamer knowledge.

For enabling dsexample with deepstream-app, you just need to add following config group to your deepstream-app config file(DeepStream Reference Application - deepstream-app — DeepStream DeepStream Version: 5.0 documentation).


Thank you Fiona.Chen.

I am tring and learning gstream.