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)“Serif”;
txt_params->font_params.font_size = 10;
txt_params->font_params.font_color.red = 0.0;
txt_params->font_params.font_color.green = 0.0;
txt_params->font_params.font_color.blue = 0.0;
txt_params->font_params.font_color.alpha = 1.0;
/* Text background color */
txt_params->set_bg_clr = 1;
txt_params->text_bg_clr.red = 1.0;
txt_params->text_bg_clr.green = 1.0;
txt_params->text_bg_clr.blue = 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