Is there any way to display FPS data via OSD?

I use python app. There is a function :“def osd_sink_pad_buffer_probe(pad,info,u_data)” used to display object detection results. How could I modify this function to add FPS to the display?

• Hardware Platform (Jetson / GPU) Titan V
• DeepStream Version 5.0
• JetPack Version (valid for Jetson only)
• TensorRT Version 7.0.11
• NVIDIA GPU Driver Version (valid for GPU only) 410.33

You want to overlay FPS value onto screen, correct?

@Amycao Thanks for the reply. And, yes, I want to overlay the fps value onto the video via OSD. Like, adding an extra FPS in the code below:

        py_nvosd_text_params.display_text = "Frame Number={} Number of Objects={} Vehicle_count={} Person_count={}". \
    format(frame_number, num_rects, obj_counter[PGIE_CLASS_ID_VEHICLE], obj_counter[PGIE_CLASS_ID_PERSON])

But I do not know if there is any function or package to fulfill this purpose. Thanks.

You may refer to deepstream-imagedata-multistream python sample, for how to get fps, get fps function defined in common module, python/apps/common/
then insert the value got into the code
py_nvosd_text_params.display_text = “Frame Number={} Number of Objects={} Vehicle_count={} Person_count={}”.
format(frame_number, num_rects, obj_counter[PGIE_CLASS_ID_VEHICLE], obj_counter[PGIE_CLASS_ID_PERSON])

@Amycao. I have explored the multimedia app you suggested. The code is like this:

   # Get frame rate through this probe

So, I need to modify and insert it as:

FPS = fps_stream.get_fps() #I have only one source stream, indexed as 0.
py_nvosd_text_params.display_text = “Frame Number={} Number of Objects={} Vehicle_count={} Person_count={} FPS={}”.
    format(frame_number, num_rects, obj_counter[PGIE_CLASS_ID_VEHICLE], obj_counter[PGIE_CLASS_ID_PERSON], FPS)

Is it correct?

1 Like

Seems correct.

Hey @HIVE , I was wondering if you were able to print your FPS on screen.
In my case, I have only 1 stream as well, but your code gives the following output:

fps = GETFPS(0).get_fps() #I have only one source stream, as well.
py_nvosd_text_params.display_text = “FPS={}”.format(fps)

Output: FPS=None

This happened to you too?
Any ideas?

Hello happened to me also.
If you go look at the in common folder it does not return FPS instead it measures FPS every 5 seconds and prints it. You can add this function to file to return FPS every time its called.

def calc_fps(self):
elapsed_time = end_time - self.start_time
current_fps = 1.0/float(elapsed_time)
str_fps = “%.1f”%(current_fps)
return str_fps

1 Like

Result using clac_fps() function
FPS = <bound method GETFPS.calc_fps of <common.FPS.GETFPS object at 0x7fa9ae08d0>>

FPS = fps_stream.calc_fps()
Print("FPS = {}".format(FPS))

The only thing different is the quotes you have used in your code vs mine "

Using the get_fps() function, the return was “None”

FPS = None