Cannot read raw tensor data of output layers using Probe Function!

Hi,

We are trying to add probe function right after primary inference of Python apps/­deepstream-test2 example and get output meta data. But we get empty result:
NvDsFrameMeta.num_obj_meta is 0
NvDsFrameMeta.obj_meta_list is None
NvDsFrameMeta.frame_user_meta_list is None

Please let us know, where did we make mistake? The code fragment related to Probe Function is below. Full source code is in the attachment.

print("Adding elements to Pipeline \n")
pipeline.add(source)
pipeline.add(h264parser)
pipeline.add(decoder)
pipeline.add(streammux)
pipeline.add(pgie)
pipeline.add(tracker)
pipeline.add(sgie1)
pipeline.add(sgie2)
pipeline.add(sgie3)

pipeline.add(nvvidconv)
pipeline.add(nvosd)

pipeline.add(nvvidconv1)
pipeline.add(videoconverter)
pipeline.add(x264enc)
pipeline.add(qtmux)

pipeline.add(sink)
if is_aarch64():
    pipeline.add(transform)

#...

#Let's add probe to get informed of the meta data generated
pgiesinkpad = pgie.get_static_pad("sink")
if not pgiesinkpad:
    sys.stderr.write(" Unable to get sink pad of pgie \n")
pgiesinkpad.add_probe(Gst.PadProbeType.BUFFER, pgie_sink_pad_buffer_probe, 0)
#The Probe Function:
def pgie_sink_pad_buffer_probe(pad, info, u_data):
    gst_buffer = info.get_buffer()
    if not gst_buffer:
        print("Unable to get GstBuffer ")
        return

    # Retrieve batch metadata from the gst_buffer
    # Note that pyds.gst_buffer_get_nvds_batch_meta() expects the
    # C address of gst_buffer as input, which is obtained with hash(gst_buffer)
    batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
    l_frame = batch_meta.frame_meta_list
    while l_frame is not None:
        try:
            # Note that l_frame.data needs a cast to pyds.NvDsFrameMeta
            # The casting is done by pyds.NvDsFrameMeta.cast()
            # 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.NvDsFrameMeta.cast(l_frame.data)
        except StopIteration:
            break

        frame_number = frame_meta.frame_num
        num_rects = frame_meta.num_obj_meta
        l_obj = frame_meta.obj_meta_list
        print("frame: ", frame_number)
        print("num rects: ", num_rects)
        print(frame_meta.frame_user_meta_list)
        print("l_obj: ", l_obj )
        try:
            l_frame = l_frame.next
        except StopIteration:
            break

    return Gst.PadProbeReturn.OK[deepstream-test2.zip|attachment]

Hardware Config

• Hardware Platform: Tesla T4
• DeepStream Version: 5.0
• TensorRT Version: 7.2.1
• NVIDIA GPU: Driver Version 455.32, CUDA Version 11.1

(upload://kkQt1JdXg5QgpUAHo1Hc4dSfemv.zip) (19.9 KB)

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)

Thanks

Hi kayccc, I updated hardware information to the post. Please check it.
Thanks

Can the sample deepstream-ssd-parser work in your platform?

1 Like

After reading source code of deepstream-ssd-parser example, I found my mistake.

I got pgie_pad in wrong way:

pgie_pad = pgie.get_static_pad("sink")

The right must be:

pgie_pad = pgie.get_static_pad("src")

Now I can get information.

Thank for your support!