You can refer to below change to measure the fps
diff --git a/deepstream_test2_app.c b/deepstream_test2_app.c
index 949219f..e8ed8f7 100644
--- a/deepstream_test2_app.c
+++ b/deepstream_test2_app.c
@@ -80,6 +80,12 @@ guint sgie1_unique_id = 2;
guint sgie2_unique_id = 3;
guint sgie3_unique_id = 4;
+typedef struct _perf_measure{
+ GstClockTime pre_time;
+ GstClockTime total_time;
+ guint count;
+}perf_measure;
+
/* This is the buffer probe function that we have registered on the sink pad
* of the OSD element. All the infer elements in the pipeline shall attach
* their metadata to the GstBuffer, here we will iterate & process the metadata
@@ -96,9 +102,27 @@ osd_sink_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
NvDsMetaList * l_frame = NULL;
NvDsMetaList * l_obj = NULL;
NvDsDisplayMeta *display_meta = NULL;
+ GstClockTime now;
+ perf_measure * perf = (perf_measure *)(u_data);
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
+ now = g_get_monotonic_time();
+
+ if (perf->pre_time == GST_CLOCK_TIME_NONE) {
+ perf->pre_time = now;
+ perf->total_time = GST_CLOCK_TIME_NONE;
+ } else {
+ if (perf->total_time == GST_CLOCK_TIME_NONE) {
+ perf->total_time = (now - perf->pre_time);
+ }
+ else {
+ perf->total_time += (now - perf->pre_time);
+ }
+ perf->pre_time = now;
+ perf->count++;
+ }
+
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
@@ -476,6 +501,13 @@ main (int argc, char *argv[])
}
#endif
+ perf_measure perf_measure;
+ int src_cnt = 1; // the source number, set to 1 temporarily
+
+ perf_measure.pre_time = GST_CLOCK_TIME_NONE;
+ perf_measure.total_time = GST_CLOCK_TIME_NONE;
+ perf_measure.count = 0;
+
/* Lets add probe to get informed of the meta data generated, we add probe to
* the sink pad of the osd element, since by that time, the buffer would have
* had got all the metadata. */
@@ -484,7 +516,7 @@ main (int argc, char *argv[])
g_print ("Unable to get sink pad\n");
else
gst_pad_add_probe (osd_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
- osd_sink_pad_buffer_probe, NULL, NULL);
+ osd_sink_pad_buffer_probe, &perf_measure, NULL);
gst_object_unref (osd_sink_pad);
/* Set the pipeline to "playing" state */
@@ -499,6 +531,7 @@ main (int argc, char *argv[])
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
+ g_print ("Average fps %f\n",((perf_measure.count-1)*src_cnt*1000000.0)/perf_measure.total_time);
gst_object_unref (GST_OBJECT (pipeline));
g_source_remove (bus_watch_id);
g_main_loop_unref (loop);