How Can get FPS in apps python in deepstream

Jetson Nano
Jetpack 4.5
Deepstream 5.1

I have a single source single stream setup.
I tried using this solution for single stream but the FPS result is returned as None

Please read the code in apps/common/ get_fps() is not to get FPS value so there is no result. You can not print the result. It is open source, please use it as the code itself.

Oh I understand my mistake, So just calling function should do make it work.

But in just calling the function like this


Yields the same result as "None"

Am I still missing something ?

Can you upload the whole code but not pieces? Where did you get “None”.

You must run fps_stream.get_fps() in a loop thread. Please read the code.

The code

while l_frame is not None:
            # Note that needs a cast to pyds.NvDsFrameMeta
            # The casting is done by pyds.glist_get_nvds_frame_meta()
            # The casting also keeps ownership of the underlying memory
            # in the C code, so the Python garbage collector will leave
            # it alone.
            #frame_meta = pyds.glist_get_nvds_frame_meta(
            frame_meta = pyds.NvDsFrameMeta.cast(
        except StopIteration:

        num_rects = frame_meta.num_obj_meta
        while l_obj is not None:
                # Casting to pyds.NvDsObjectMeta
            except StopIteration:
            obj_counter[obj_meta.class_id] += 1
            obj_meta.rect_params.border_color.set(0.0, 0.0, 1.0, 0.0)
            rect_params = obj_meta.rect_params
            #print("Name = {} ,Top = {}, Left = {}, Height = {}, Width = {}".format(pgie_classes_str[obj_meta.class_id],int(,int(rect_params.left),int(rect_params.height),int(rect_params.width)))
            print("Class_ID =",obj_meta.class_id)
            except StopIteration:

        # Acquiring a display meta object. The memory ownership remains in
        # the C code so downstream plugins can still access it. Otherwise
        # the garbage collector will claim it when this probe function exits.
        display_meta.num_labels = 1
        py_nvosd_text_params = display_meta.text_params[0]
        # Setting display text to be shown on screen
        # Note that the pyds module allocates a buffer for the string, and the
        # memory will not be claimed by the garbage collector.
        # Reading the display_text field here will return the C address of the
        # allocated string. Use pyds.get_string() to get the string content.


        # Now set the offsets where the string should appear
        py_nvosd_text_params.x_offset = 10
        py_nvosd_text_params.y_offset = 12

        # Font , font-color and font-size
        py_nvosd_text_params.font_params.font_name = "Serif"
        py_nvosd_text_params.font_params.font_size = 10
        # set(red, green, blue, alpha); set to White
        py_nvosd_text_params.font_params.font_color.set(1.0, 1.0, 1.0, 1.0)

        # Text background color
        py_nvosd_text_params.set_bg_clr = 1
        # set(red, green, blue, alpha); set to Black
        py_nvosd_text_params.text_bg_clr.set(0.0, 0.0, 0.0, 1.0)
        # Using pyds.get_string() to get display_text as string
        pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta)
        except StopIteration:

Also I have used the imports

import sys
import gi
import time
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
from common.is_aarch_64 import is_aarch64
from common.bus_call import bus_call
from common.FPS import GETFPS
import pyds

You can not use “fps_stream=GETFPS(1)” in the loop thread. Please place it in main thread. I think we already have such sample in deepstream-test3

1 Like