先上结果图片
main函数添加定义:
GstElement *nvsink = NULL;
将这一句代码注释:
//sink = gst_element_factory_make ("nveglglessink", "nvvideo-renderer");
然后添加下面代码
nvsink = gst_element_factory_make("nveglglessink", "nvvideo-renderer");
sink = gst_element_factory_make("fpsdisplaysink", "fps-display");
g_object_set(G_OBJECT(sink), "text-overlay", FALSE, "video-sink", nvsink, "sync", FALSE, NULL);
将倒数第二个NULL参数
gst_pad_add_probe(osd_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
osd_sink_pad_buffer_probe, NULL, NULL);
改成:
gst_pad_add_probe(osd_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
osd_sink_pad_buffer_probe, (gpointer)sink, NULL);
最后在osd_sink_pad_buffer_probe显示地方添加如下关键代码:
gchar *msg = NULL;
g_object_get(G_OBJECT(u_data), "last-message", &msg, NULL);
if (msg != NULL)
{
g_print("Fps info: %s\n", msg);
}
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, msg);
参考issue:FPS in test apps. - DeepStream SDK - NVIDIA Developer Forums