Attaching User Metadata to GStreamer Buffer using Python Bindings

Please provide complete information as applicable to your setup.

**• Hardware Platform: GPU
**• DeepStream Version 6.1
**• TensorRT Version 8.4.1
• NVIDIA GPU Driver Version (valid for GPU only)
**• Issue Type (questions)

I’m trying to use the Deepstream python bindings to attach a NumPy array as custom metadata, using pyds.gst_buffer_add_nvds_meta. Are there any examples involving this function or attempting to do what I am trying to do? I’ve checked the sample apps, but the closest thing is test4 which does not try to add any data.

I want to add this NumPy array and then access this array in a probe attached to the NvInfer element. I want this data to be available when I receive the inferenced object metadata in my nvinfer probe.

Thanks!

Hi @abiramgupta8 , you can refer our c demo code.

/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-gst-metadata-test/deepstream_gst_metadata.c

Hi, I referred to that c demo code, but I’m a little unsure as to how to translate it into Python, especially the copy and free functions.

How should I use memdup and implement the copy, free, release, and transform functions in Python? Are there any examples of achieving this in Python using the pyds bindings?

Thanks!

I referred to this post: https://forums.developer.nvidia.com/t/adding-custom-metadata-upstream-of-nvstreammux-with-python/214606], but it seems there was no resolution. When trying to use gst_buffer_add_nvds_meta, I get the following error:
TypeError: gst_buffer_add_nvds_meta(): incompatible function arguments. The following argument types are supported:
1. (buffer: _GstBuffer, meta_data: capsule, user_data: capsule, copy_func: void* (void*, void*), release_func: void (void*, void*)) → _NvDsMeta

How do I write and pass in the copy and release functions? I appreciate any help.

About the copy and release func, you can refer the

nvds_batch_meta_copy_func and nvds_batch_meta_release_func

from the link
https://docs.nvidia.com/metropolis/deepstream/python-api/PYTHON_API/Methods/methodsdoc.html#nvds-batch-meta-copy-func
It just send the right paras( NvDsBatchMeta datastructure, your datastructure).

Do I pass these functions in as the copy and release functions? If so, that does not work, and I still run into the previous error.

Is there any working example of the python gst_buffer_add_nvds_meta()? I’ve looked all over the forum, and it seems others have been running into the same issues implementing this functionality in python. None of the python examples use this function, so if you can point me towards a resource that is similar to deepstream_gst_metadata.c but for python - I’d be super regretful!

I need to pass in my own metadata at the source element, and the gst_buffer_add_nvds_meta is perfect to do so. However, the documentation and examples for this function is lacking - I’m not sure how to pass in the requisite functions.

Hi @abiramgupta8 , we do not have python examples about this at present. We will confirm whether similar python examples will be added in the future. Thanks

Do you have any guidance on how I can implement these functions in Python? Or how to actually pass in the copy and release functions?

We’ll develop it and provide a guide for this in the future version.

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

Hi @abiramgupta8 , we have updated the open source code. Please refer to: https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/tree/master/bindings/src/custom_binding. But it needs DeepStream 6.2.

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