Need example which implements the nvds_msg2p interface for custom schema needs to be integrated with the DeepStream SDK

• Hardware Platform (Jetson / GPU): GeForce GTX 1050Ti
• DeepStream Version: 5.0.1
• Issue Type( questions, new requirements, bugs): questions

I’m using DeepStream 5.0.1 with dGPU docker and working on example DeepStream Test 5 app with Azure. I want to add custom fields, both static and dynamic to the existing schema. I found this link which mentioned about implementing nvds_msg2p interface. They asked to refer sources/libs/nvmsgconv/nvmsgconv.cpp for example.
Can anyone help with full flow example to implement nvds_msg2p interface and changes required in config and lib files?

/opt/nvidia/deepstream/deepstream-5.0/sources/libs/nvmsgconv/nvmsgconv.cpp is the complete sample of implementing nvds_msg2p interfaces. /opt/nvidia/deepstream/deepstream-5.0/sources/libs/nvmsgconv/nvmsgconv.cpp is based on json-glib https://developer.gnome.org/json-glib/stable/ to generate json content.

The source codes are simple and explicit. You can write your own cpp file to implement nvds_msg2p interfaces, and build the cpp file into dynamic library. “msg2p-lib” property of nvmsgconv plugin can help you to enable your new library.

Another way is to reuse the existing libnvds_msgconv.so by just modify /opt/nvidia/deepstream/deepstream-5.0/sources/libs/nvmsgconv/nvmsgconv.cpp and /opt/nvidia/deepstream/deepstream-5.0/sources/libs/nvmsgconv/nvmsgconv.h, rebuild the library, your new scheme will be in use. Gst-nvmsgconv — DeepStream 6.1.1 Release documentation

@Fiona.Chen Thanks for the reply. I’m already trying changes as per second option by modifying /opt/nvidia/deepstream/deepstream-5.0/sources/libs/nvmsgconv/nvmsgconv.cpp. But somehow it’s not succeeding. Can you please mention the steps to add a custom parameter in Sensor Object? It would be helpful if you can provide the list of files to be modified with step by step examples.

It is too abstract to understand your requirement. And we have no idea about your failure of changing nvmsgconv.cpp because you told us nothing about your change.

@Fiona.Chen, I just need a simple end to end example and list of steps to add one more parameter in sensor object from msgconv config file. Let’s assume default sensor object in existing test5 app is:
[sensor0]
enable=1
type=Camera
id=HWY_20_AND_LOCUST__WBA__4_11_2018_4_59_59_379_AM_UTC-07_00
location=45.293701447;-75.8303914499;48.1557479338
description=Aisle Camera
coordinate=5.2;10.1;11.2

And I just want to add one more static parameter, say ‘aisle_name=lane 1’ to this list:

[sensor0]
enable=1
type=Camera
aisle_name=lane 1
id=HWY_20_AND_LOCUST__WBA__4_11_2018_4_59_59_379_AM_UTC-07_00
location=45.293701447;-75.8303914499;48.1557479338
description=Aisle Camera
coordinate=5.2;10.1;11.2

So I just need this ‘aisle_name’ to get in the output JSON generated as message.I’m already referring the document Gst-nvmsgconv — DeepStream 6.1.1 Release documentation.
Just need an example to add static or dynamic parameters to message JSON to be sent to Azure from config file.
Let me know if you need any more clarification.

The nvmsgconv.cpp is the sample code itself. It is very clear and simple.
You can refer to nvds_msg2p_parse_sensor() and generate_sensor_object() for how the sensor parameters are read from the msgconv config file and be generated as the corresponding Json file member.
Besides, you need to get familiar with json-glib to read the code. https://developer.gnome.org/json-glib/stable/

But still some steps are there which are not mentioned anywhere, like how to add these new parameters to NvDsEventMsgMeta. Now I figured it out and added it in nvdsmeta_schema.h file. But somehow I’m still not getting the proper value from msgconv config file. Do I need to add same custom parameter in test5 app as well?

Please check generate_sensor_object() function, it uses the “sensorId” of NvDsEventMsgMeta to find out the corresponding senbsorObj(every sensorObj has identified sensor id), when you get the senbsorObj, you can get all items in sensorObj.
You don’t need to modify NvDsEventMsgMeta.

If I don’t add these parameters inside NvDsEventMsgMeta, then I get error:
Unknown key aisle_name for group [sensor0]
I checked sensorObj has only predefined values not the custom one which I added.

Seems you have not implemented your new parameter with nvds_msg2p_parse_sensor() correctly.

You can take CONFIG_KEY_LOCATION as an example, please check how it is defined and used in nvds_msg2p_parse_sensor() and generate_sensor_object().

Codes are already there, you need to read and understand by yourself.

After getting errors, I already added it in nvds_msg2p_parse_sensor().
Since there is no document from Nvidia which mentions these steps clearly, it could be tough for new people like me, using DeepStream in their apps. We need to go through all over the code, check the flow and then correct the issues as and when we get them. I was expecting some clear steps with simple examples, so posted here in forums. But looks like you have only code itself to understand and do the trials. Thank you.

2 Likes