Add user secific metadata for a deepstream pipeline

Hello,

I want to add my own custom data or class in deep stream pipeline.
I tried to refer this linkhttps://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_metadata.html#user-custom-metadata-addition-inside-nvdsbatchmeta but it is little difficult as i need to modify .c and .h files.

Can someone help me, as to how add custom data in header and source file and give a build so that we can access these new metadata variable and update in our post processing logic.

Also need support for any python code snippet as to how to access and modify those new meta data inside python code.

Example to explain a scenario:
Let’s say we are accessing a live surveillance camera feed for our use cases. I want to use the location information of that surveillance video as a one of metadata and attach it with an alert. This alert is nothing but a frame snippet whenever when any violation is recorded. That alert frame should be saved with a name that includes the surveillance camera information. Since this metadata is unique in my case, it is not present in default metadata available withing deep stream docker. Hence, I want to add these new metadata using the steps provided in above link. But that is not clear.
Any support is highly appreciated.

Setup details:
GPU: L4
Deep Stream version: 6.4

Thanks and Regards,
Udaykiran Patnaik.

Please following this FAQ

Thanks for the suggestion. While I try to modify the files, how do i give a build to ensure that changes done are reflected inside the docker. Is there any specific step that I need to follow? Kindly support.

Thanks and Regards,
Udaykiran Patnaik.

Recompile and install according to the README in /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-dsexample and rebuild the python bindings

1 Like

Hello Team,

When we recompile using steps according to readme, it gives rise to an error. The log (gst_plugin_compilation_error.txt) is attached for your reference.

Note: we are using following docker image:
Image :nvcr.io/nvidia/deepstream:6.4-samples-multiarch

gst_plugin_compilation_error.txt (491.1 KB)

Kindly support to resolve the error.

Thanks and Regards,
Udaykiran Patnaik.

1.Don’t use the docker image of 6.4-samples-multiarch. It’s just for deploy binary and and does not contain the CUDA header file.
deepstream:6.4-triton-multiarch is for development

2.DS-6.4 only works on CUDA 12.2.It is included in the docker image
https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html#id6

Hi, thanks we are able to build using above methods and able to access the custom metadata in python as provided above example(timestamp). But
Issue 1:
when we added new custom data by modifying the cpp file and corresponding python and build the solution as mentioned above, we are unable to access newly added metadata inside python. Are we missing something to update? Kindly support.

PFA the modified files. Kindly change the extension to cpp and py wherever applicable.
bindnvdsmeta.txt (28.2 KB)
deepstream_test_1.txt (10.6 KB)
gstdsexample.txt (38.6 KB)

Error logs when running following command:
python3 deepstream_test_1.py sample_720p.h264

Attached DsExampleMeta from native ==> cur 1713965726930.172 ms
Attached DsExampleMeta from native 1 ==> Camera Name Gudimalkapur Junction Camera
access dsmeta from python cur 1713965726930.172 ms
Traceback (most recent call last):
  File "/opt/nvidia/deepstream/deepstream-6.4/sources/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py", line 69, in osd_sink_pad_buffer_probe
    print(f"access dsmeta from python {pyds.get_string(dsexample_meta.cameraname)}")
AttributeError: 'pyds.DsExampleMeta' object has no attribute 'cameraname'

Thanks and Regards,
Udaykiran Patnaik.

There seems to be no problem with the code. I guess it may be caused by incorrect installation and deployment.

rebuild and install dsexample plugin

cd /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-dsexample

make CUDA_VER=12.2 install

rebuild and install python bindings.

cd /opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/build

make

pip install -U ./pyds-1.1.10-py3-none-linux_aarch64.whl 

If the above directory does not exist, please refer to the READE above.

Hi @junshengy ,

We followed above steps but the same issue error was observed.
The only difference is hardware architecture. In our case it is

pyds-1.1.10-py3-none-linux_x86_64.whl
We used GPU as A2000 for testing.

Thanks and Regards,
Udaykiran Patnaik.

CPU architecture makes no difference.
Try uninstalling and then reinstalling, this should be a problem caused by python bindings.
I ran your code and they didn’t have any issues

pip uninstall pyds

cd /opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/build

pip install ./pyds-1.1.10-py3-none-linux_aarch64.whl 
Attached DsExampleMeta from native 1 ==> Camera Name Gudimalkapur Junction Camera
access dsmeta from python Camera Name Gudimalkapur Junction Camera
Frame Number=1439 Number of Objects=22 Vehicle_count=19 Person_count=3
Attached DsExampleMeta from native 1 ==> Camera Name Gudimalkapur Junction Camera
access dsmeta from python Camera Name Gudimalkapur Junction Camera
Frame Number=1440 Number of Objects=23 Vehicle_count=20 Person_count=3
Attached DsExampleMeta from native 1 ==> Camera Name Gudimalkapur Junction Camera
access dsmeta from python Camera Name Gudimalkapur Junction Camera
Frame Number=1441 Number of Objects=2 Vehicle_count=2 Person_count=0

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

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