Get metadata from nvinfer in Python for multiple streams

Consider the official deepstream example deepstream_test1_rtsp_in_rtsp_out.py that can be found here: deepstream_python_apps/deepstream_test1_rtsp_in_rtsp_out.py at master · NVIDIA-AI-IOT/deepstream_python_apps · GitHub
As you can see, at line 59 of the script, you can find the function tiler_src_pad_buffer_probe. This function is not currently used in the example. You can simply double check it with a Ctrl-F.
I’d like to use that function to retrieve the metadata associated to each stream.

So far I have been able to do this:

        osdsinkpad = nvosd.get_static_pad("sink")
        if not osdsinkpad:
            sys.stderr.write(" Unable to get sink pad of nvosd \n")

        osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, self.tiler_src_pad_buffer_probe, 0)

This let me retrieve the number of detections but unfortunately, since nvosd is placed after nvmultistreamtiler it won’t allow me to discern the streams. In fact I believe that after the nvmultistreamtiler there will be a unique stream. In fact, frame_meta.pad_index in function tiler_src_pad_buffer_probe will always return 0.

I tried this:

        osdsinkpad = nvosd.get_static_pad("pgie")
        if not osdsinkpad:
            sys.stderr.write(" Unable to get sink pad of pgie \n")

        osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, self.tiler_src_pad_buffer_probe, 0)

Unfortunately this does not work as it does not retrieve any metadata. It does not throw any error, but the number of people and vehicles are always 0 even if I can see that the pipeline has detected them because I see cars bounding boxes in the output rtsp stream.

How can I retrieve the metadata associated to the object detection to each stream? I’d like know the bounding boxes and detection class of each object detected in each stream.
E.g.

  • stream 1 has 1 car at position x0,y0
  • stream 2 has has 2 cars at position x1,y1 and x2,y2
  • stream 3 has 0 cars

Solved:

        tiler_src_pad = pgie.get_static_pad("src")
        if not tiler_src_pad:
            sys.stderr.write(" Unable to get src pad \n")
        else:
            tiler_src_pad.add_probe(Gst.PadProbeType.BUFFER, self.tiler_src_pad_buffer_probe, 0)

Thanks for the update.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.