Batch synchronization with probe

• Hardware Platform (Jetson / GPU) Jetson Orin Nano
• DeepStream Version 7.0
• JetPack Version (valid for Jetson only) 6.0

Hi, I’m trying to extract the position of objects detected with a probe. The PGIE has a batch-size=9, so I run through 9 frames per batch. When I extract the position of the objects, I get the right dimensions and coordinates, but it’s never the right frame.

I use batch_id to find my way through the frame count, it always goes from 0 to 8 but I don’t touch frame_meta.frame_num because it gives me the batch number since the start of the program. The OSD always shows the objects surrounded by a red rectangle in the right place, so I don’t understand why I can’t capture the right frame number.

For the record, I don’t use GLib.MainLoop() because I use a state machine on the side and it simplifies my work.

Here is my probe :

def tracker_src_pad_buffer_probe(self,pad,info,u_data):
        gst_buffer = info.get_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:
            # 1 frame (1 tile)
            try:
                frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
            except StopIteration:
                break

            batch_id = frame_meta.batch_id
            total_batch_number = frame_meta.frame_num # Batch number since the programm started
            

            l_obj=frame_meta.obj_meta_list
            while l_obj is not None:
                try:
                    obj_meta = pyds.NvDsObjectMeta.cast(l_obj.data)
                except StopIteration:
                    break

                class_id = obj_meta.class_id
               
                if self.run_calibration:
                    left = obj_meta.rect_params.left
                    top = obj_meta.rect_params.top
                    right = left + obj_meta.rect_params.width
                    bottom = top + obj_meta.rect_params.height
                    center = ((right+left)//2,(bottom+top)//2)
                    # Positions always correct but when I look at the batch_id, it never matchs.

                try:
                    l_obj = l_obj.next
                except StopIteration:
                    break

            try:
                l_frame = l_frame.next
            except StopIteration:
                break

        return Gst.PadProbeReturn.OK

Do you have any ideas, or do you need more information? Thank you in advance.

It behaves how it should be following NVIDIA DeepStream SDK API Reference, batch_id is just frame index for that batch only.

You can look at this example deepstream_imagedata-multistream.py

1 Like

Indeed, but I thought it would be the same for pad_index. Solved by replacing batch_id with pad_index. Thanks for your answer.

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