Python add user meta data to batch_meta

Please provide complete information as applicable to your setup.

• Hardware Platform (GPU)
• DeepStream Version 5.1
• TensorRT 7.2
• NVIDIA GPU Driver Version 4.55.23.0.5
• Issue Type(bugs)
**• How to reproduce the issue ? **

we are trying to add user_meta_data to batch_meta data to transfer data between plugins
we looked into deepstream-user-metadata-test.c app to for reference to write code for our
python plugin.

1: For start we used pyds.nvds_get_user_meta_type(“NVDS_USER_META_OUR_CASE”) as mentioned
in your python documentation to create custom type but when ever we run this

        CustomMetadata.Type = pyds.nvds_get_user_meta_type("NVDS_USER_META_OUR_CASE")
        print(CustomMetadata.Type)

         we get this in the output.

         **NvDsMetaType.???**

2: user_meta: pyds.NvDsUserMeta = pyds.nvds_acquire_user_meta_from_pool(batch_meta)
pyds.user_copyfunc(user_meta, metadata.copy)
pyds.user_releasefunc(user_meta, metadata.release)
the function metadata.copy and metadata.release never ran and these lines produce no errors

**3:**we used Cython to generate capsule instance to attach it to user_meta_data
custom_obj = metadata.CustomMetadata()
user_meta: pyds.NvDsUserMeta = pyds.nvds_acquire_user_meta_from_pool(batch_meta)
pyds.user_copyfunc(user_meta, metadata.copy)
pyds.user_releasefunc(user_meta, metadata.release)

        test = Test()
        Test.peek(test.vars)
        user_meta.user_meta_data = test.vars
        print("user_meta.", user_meta.user_meta_data)
        user_meta.base_meta.meta_type = metadata.CustomMetadata.Type
        pyds.nvds_add_user_meta_to_batch(batch_meta, user_meta)

        **below code is to convert python data to capsule instance**

Blockquote> #cython: language_level=3

from cpython.pycapsule cimport PyCapsule_New, PyCapsule_IsValid, PyCapsule_GetPointer

class Test:
def init(self):
cdef int test = 10
cdef const char *name = “test”
self.vars = PyCapsule_New(<void *>&test, name, NULL)

@staticmethod
def peek(self):
    cdef const char *name = "test"
    if not PyCapsule_IsValid(self, name):
        raise ValueError("invalid pointer to parameters")
    cdef int test = <int >PyCapsule_GetPointer(self, name)
    print(test[0])

    # Print pointer address
    print("{0:x}".format(<unsigned long long>test))
    
def get_caps(self):
    cdef int test = 10
    cdef const char *name = "test"
    return PyCapsule_New(<void *>&test, name, NULL)
    
    # Print pointer address
    #print("{0:x}".format(<unsigned long long>test))

there are no errors on assaigning the capsule instance but when we received data on the other plugin we
get <capsule object NULL at 0x7f18db86a5a0>

The meta_type is not string type. NVIDIA DeepStream SDK API Reference: Metadata Structures | NVIDIA Docs

Please debug your code

The meta_type is not string type. NVIDIA DeepStream SDK API Reference: Metadata Structures

Here in your documentation it is taking string as an argument:
https://docs.nvidia.com/metropolis/deepstream/python-api/PYTHON_API/Methods/methodsdoc.html#nvds-get-user-meta-type

In your documentation

https://docs.nvidia.com/metropolis/deepstream/sdk-api/group__metadata__structures.html#ggafe355a3b337b0ac13e25394dddf6a63fa406287ab4e6a314d51cf3bc0788afc2b
it is mentioned that we can add “user specific meta types” at the end of enum NvDsMetaType.
In python we can not add value to the enum at runtime, can you please explain how we can add our custom type to enum NvDsMetaType.

2 .
we can access meta data generated by nv_infer down the pipeline
but we are not able to add our custom data to the buffer.
The aim is to attach meta data from a plugin and access that meta data from different plugin down the pipeline.

Hi @ahsaanraazaa ,
I tried both
user_meta.user_meta_data = test.vars
user_meta.user_meta_data = pyds.NvDsUserMeta.cast(test.vars)
and still have same problems <capsule object NULL at 0x7f18db86a5a0>
Did you solve your problems ?

Nope

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

There is sample of the usage for pyds.nvds_add_user_meta_to_frame in deepstream_python_apps/deepstream_test_4.py at master · NVIDIA-AI-IOT/deepstream_python_apps (github.com), it is the similar case.

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