How to add user_meta_data to NvMeta objects from Python?


I am trying to add a custom meta-data (a python string, for example) to the NvMeta object that is passed between deepstream plugins.

Let’s say I want to attach this custom meta-data to the frame_meta (pyds.NvDsFrameMeta). I found out that I should use [pyds. nvds_add_user_meta_to_frame] ( for this.

But I have some problems with creating the NvDsUserMeta to attach to the NvDsFrameMeta.

I tried something like:

meta = pyds.NvDsUserMeta()
meta.user_meta_data = “some string”

but I get this:

TypeError: (): incompatible function arguments. The following argument types are supported:
1. (self: pyds.NvDsUserMeta, arg0: capsule) -> None

Then, I tried to convert the python object into a kind of ctype reference using ctypes with no success.

I have read deepstream_gst_metadata.c and understand how this all works in C.

Please help me understand how to do this properly in Python. I think what would me help is to know how to convert a Python object reference to a void pointer of C and vice-versa.


Refer to , it supports below to methods:

pyds.NvDsUserMeta.cast(self: capsule)
pyds.NvDsUserMeta.cast(self: int)