FPS in test apps.

I am tring to get FPS of the deepstream-test3-app pipeline. I am not able to understand the reference deepstream_perf.c file. I have changed the deepstream-test3-app to look as follows:

double t , p=0;
int frame_count_cam0=0; 
int frame_count_cam1=0;
static GstPadProbeReturn
tiler_src_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
    gpointer u_data)
{
    GstBuffer *buf = (GstBuffer *) info->data;
    guint num_rects = 0; 
    NvDsObjectMeta *obj_meta = NULL;
    guint vehicle_count = 0;
    guint person_count = 0;
    NvDsMetaList * l_frame = NULL;
    NvDsMetaList * l_obj = NULL;
    gboolean is_first_object = TRUE;
    NvDsDisplayMeta *display_meta = NULL;

    NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);

    for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {
        NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
        int offset = 0;
        for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
                l_obj = l_obj->next) {
            obj_meta = (NvDsObjectMeta *) (l_obj->data);
            if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
                vehicle_count++;
                num_rects++;
            }
            if (obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
                person_count++;
                num_rects++;
            }
        
#if 0
        display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
        NvOSD_TextParams *txt_params  = &display_meta->text_params;
        txt_params->display_text = 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;
	
	
        nvds_add_display_meta_to_frame(frame_meta, display_meta);
#endif
    
     t = ((double)clock())/CLOCKS_PER_SEC;
     if((int)t - (int)p>=1)
     {
     	g_print("%f %d %d\n ", t , frame_count_cam0, frame_count_cam1); 
     	p=t;
     	frame_count_cam0=0;
     	frame_count_cam1=0; 
     }
     if(frame_meta->source_id==0){
        frame_count_cam0++;
     }
     else{
        frame_count_cam1++;
     }
    return GST_PAD_PROBE_OK;
}

But I get 70 to 80 FPS on RTSP stream hence not sure about my method. Can anyone post a sample code to do that?

Hi,
Please utilize fpsdisplaysink:

GstElement *nvsink = NULL;

  /* Finally render the osd output */
#ifdef PLATFORM_TEGRA
  transform = gst_element_factory_make ("nvegltransform", "nvegl-transform");
#endif
-  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);

And following modification to print out fps.
1 Pass sink object to tiler_src_pad_buffer_probe():

gst_pad_add_probe (tiler_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
        tiler_src_pad_buffer_probe, (gpointer)sink, NULL);

2 In tiler_src_pad_buffer_probe(), add the print:

gchar *msg = NULL;

g_object_get (G_OBJECT (u_data), "last-message", &msg, NULL);
if (msg != NULL) {
  g_print ("Fps info: %s\n", msg);
}

That worked like a charm! Thanks! Can I get the fps for each individual stream in the pipeline?

Hi,
All sources are packetized into one source with batch-size=SOURCE_NUMBER by nvstreammux, so it may not be able to check each source. If you need independent sources, you may run single source in each process and launch simultaneous multiple processes.

So the number that I get is the number for the complete pipeline right?

Hi,

Yes, rendering fps is the result of complete pipeline. For eliminating nveglglessink, you may replace it with fakesink.

1 Like