How to access past frame tracking results from python in DeepStream 5.0

Hello, I am trying to access the past frame tracking results from python with the new NvDsPastFrame* classes in the DeepStream 5.0 for python SDK. Until now I came up with this code:

def buffer_probe_callback(pad, info, u_data):
    gst_buffer = info.get_buffer()
    batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
    user_meta_list = batch_meta.batch_user_meta_list
    while user_meta_list is not None:
        user_meta = pyds.NvDsUserMeta.cast(user_meta_list.data)
        if user_meta.base_meta.meta_type == pyds.NvDsMetaType.NVDS_TRACKER_PAST_FRAME_META:
            print("Found past frame meta")
        try:
            user_meta_list = user_meta_list.next
        except StopIteration:
            break

Indeed this code prints the “Found past frame meta” lines. What I miss is how to extract / cast the pyds.NvDsPastFrameObjBatch instances from the user meta. Maybe some cast method is missing from this class?

Hey, I recalled you had implemented the bindings here, does this binding not work for you? pyds_tracker_meta/pyds_tracker_meta.cpp at master · mrtj/pyds_tracker_meta · GitHub

Hello, unfortunately not. When I import my bindings pyds_tracker_meta in a project where pyds is already imported, pybind11 throws an exception saying that there is already a python binding registered for the native ( C ) class NvDsPastFrameObjBatch (this is done by the new python classes in DeepStream 5.0 for python). It seems you can’t have two bindings registered for the same native ( C ) class so using DS 5.0 my library can not be imported, this is a regression compared to DS 5.0 DP.

Thanks for the info, we will check it.

Hello, I updated my library GitHub - mrtj/pyds_tracker_meta: pybind11 wrapper to access Nvidia DeepStream tracker meta info from Python. so that it works also with DeepStream 5.0 so my work is unblocked. However at this point the code in pyds_tracker_meta is really just a patch of the incomplete implementation of the official library. I feel it would have a much better place in the SDK, may I suggest to consider integrating it in the next release?

You need to use py::class_(m,“NvDsPastFrameObjBatch”,py::module_local()), py::module_local should be used, it will resolve the conflict with one in Deepstream 5.0 and his bindings.