How to draw line in deepstream 4.0

Hi,

I tried drawing line using NvOSD_LineParams,

NvOSD_LineParams *lne_params =  &display_meta->line_params[0];
lne_params = (NvOSD_LineParams *) g_malloc0 (sizeof (NvOSD_LineParams));
lne_params->x1 = 100;
		lne_params->y1 = 100;
		lne_params->x2 = 500;
		lne_params->y2 = 500;
		lne_params->line_width = 5;
		lne_params->line_color.red = 20.0;
		lne_params->line_color.green = 25.0;
		lne_params->line_color.blue = 0.0;
		lne_params->line_color.alpha = 1.0;

I couldnt see any line in video. How can I draw line using NvOSD_LineParams.

But I can able to write text in similar way,

NvOSD_TextParams *txt_params = &display_meta->text_params[0];
txt_params->display_text = (gchar *) g_malloc0 (MAX_DISPLAY_LEN);

offset =	snprintf (txt_params->display_text, MAX_DISPLAY_LEN, "Person = %d ",	person_count);
txt_params->x_offset = 10;
		txt_params->y_offset = 12;
		/* Font , font-color and font-size */
		txt_params->font_params.font_name = (gchar *) "Serif";
		txt_params->font_params.font_size = 10;
		txt_params->font_params.font_color.red = 1.0;
		txt_params->font_params.font_color.green = 1.0;
		txt_params->font_params.font_color.blue = 1.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 = 0.0;
		txt_params->text_bg_clr.green = 0.0;
		txt_params->text_bg_clr.blue = 0.0;
		txt_params->text_bg_clr.alpha = 1.0;

Where do you add these code ?

In sampleapp deepstream-infer-tensor-meta-test in osd_sink_pad_buffer_probe method.

Hi sathiez

You need to add following code to draw the line before adding display meta to framemeta.

NvOSD_LineParams *line_params  = display_meta->line_params;
       line_params[0].x1 = 400;//for demonstration, user need to se these values
       line_params[0].y1 = 400;
       line_params[0].x2 = 800;
       line_params[0].y2 = 800;
       line_params[0].line_width = 4;
       line_params[0].line_color = (NvOSD_ColorParams){1.0, 0.0, 0.0, 1.0};
       display_meta->num_lines++;

I want to draw a line on the video frame using a gst-plugin. In which place should I add the above code ?

Hi malith,

Please open a new topic for this issue. Thanks

I only can draw text or rect, can not draw line. I put this code in function overlay_graphics, deepstream_app_main.c in deepstream-app

NvDsDisplayMeta *display_meta =
nvds_acquire_display_meta_from_pool (batch_meta);

display_meta->num_labels = 1;
display_meta->text_params[0].display_text = g_strdup_printf (“Source: %s”,
appCtx->config.multi_source_config[source_ids[index]].uri);

// Draw text: work
display_meta->text_params[0].y_offset = 20;
display_meta->text_params[0].x_offset = 20;
display_meta->text_params[0].font_params.font_color = (NvOSD_ColorParams) {
0, 1, 0, 1};
display_meta->text_params[0].font_params.font_size =
appCtx->config.osd_config.text_size * 1.5;
display_meta->text_params[0].font_params.font_name = “Serif”;
display_meta->text_params[0].set_bg_clr = 1;
display_meta->text_params[0].text_bg_clr = (NvOSD_ColorParams) {
0, 0, 0, 1.0};

// Draw line: not work
display_meta->line_params[0].x1 = 400;//for demonstration, user need to se these values
display_meta->line_params[0].y1 = 400;
display_meta->line_params[0].x2 = 800;
display_meta->line_params[0].y2 = 800;
display_meta->line_params[0].line_width = 4;
display_meta->line_params[0].line_color = (NvOSD_ColorParams){1.0, 0.0, 0.0, 1.0};
display_meta->num_lines++;