[deepstream][原创]更改deepstream_test1_app在弹出视频上画一条线条
Posted FL1623863129
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[deepstream][原创]更改deepstream_test1_app在弹出视频上画一条线条相关的知识,希望对你有一定的参考价值。
要求:比如利用deepstream做车流量统计时候,我们需要画条线表明是否在线以内以外。因此需要在视频中加条线
关键代码:
display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
NvOSD_TextParams *txt_params = &display_meta->text_params[0];
display_meta->num_labels = 1;
txt_params->display_text = (char *)g_malloc0(MAX_DISPLAY_LEN);
offset = snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Person = %d ", person_count);
offset = snprintf(txt_params->display_text + offset , MAX_DISPLAY_LEN, "Vehicle = %d ", vehicle_count);
/* Now set the offsets where the string should appear */
txt_params->x_offset = 10;
txt_params->y_offset = 12;
/* Font , font-color and font-size */
txt_params->font_params.font_name = "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;
//这个就是画线代码,我在视频中心画了一个横线条
NvOSD_LineParams *line_params = display_meta->line_params;
display_meta->num_lines = 1;
line_params[0].x1 = 0;
line_params[0].y1 =1080/2;
line_params[0].x2 = 1920;
line_params[0].y2 = 1080/2;
line_params[0].line_width = 4;
line_params[0].line_color = (NvOSD_ColorParams){1.0, 0.0, 0.0, 0.5};
nvds_add_display_meta_to_frame(frame_meta, display_meta);
结果图:
以上是关于[deepstream][原创]更改deepstream_test1_app在弹出视频上画一条线条的主要内容,如果未能解决你的问题,请参考以下文章
[deepstream][原创]更改deepstream_test1_app在弹出视频上画一条线条
[deepstream][原创]deepstream:5.1-21.02-triton的docker无法使用pytorch