Using the nvdsanalytics plugin - c++ only?

• Hardware Platform (Jetson / GPU) All
• DeepStream Version 5.0 dp
• JetPack Version (valid for Jetson only)

I’m trying to use the nvdsanalytics plugin and incorporate into my C deepstream application. However I notice the header file for the user meta uses C++ vectors and unordered_map’s. Correct me if I am wrong but does this mean any user of this plugin must develop their apps in C++ now? Why does this plugin use C++ and not others? Is there a recommendation to start using c++ for deepstream applications?

I have same question. I am trying to use nvdsanalytics plugin in “/deepstream-test3/deepstream_test3.c” so that I can overlay some data from nvdsanalytics to the frame.

Unfortunately there seems to be no way unless you compile your program as C++. Or… you create another gstreamer plugin which can read the user meta created by nvdsanalytics (using C++ data structures) and write new user meta using simply C types or glib data structures. The plugin option is better I think - however its more work, so for now I have just made my app compile as c++. Only needed some minor changes to do so.

The question for NVIDIA is why?

Hey customoer,
I think nvinfer is using c++11, it will be more efficient based on the move semantic/perfect forward, so I would suggest to use c++ or modern c++, I will check internally and give your reply ASAP.

Hello @jasonpgf2a,
That means I have to create a separate plugin just to add display meta so that I can overlay those data on frame.
I am trying to add some part of deepstream-test3 into nvdsanalytics pipeline so that I can display some data on screen. But while running Makefile command I am facing this error -

deepsteam_nvdsanalytics_test.cpp:123:46: error: invalid conversion from 'gpointer {aka void*}' to 'char*' [-fpermissive]
         txt_params->display_text = g_malloc0 (MAX_DISPLAY_LEN);
deepsteam_nvdsanalytics_test.cpp:132:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
         txt_params->font_params.font_name = "Serif";

please let me know if you can help me. I have also created separate topic for this Please have a look - How to add metadata using probe and how to create encodebin for saving multiple video files
Thanks in advance

txt_params->font_params.font_name = (char *)"Serif" and do the same for the first error.

1 Like

You forgot to cast.

some_text = (char *) g_malloc(SOME_LENGTH);

g_malloc just allocates some memory of a suppled size in bytes. You need to specify what you want to use that memory as explicitly. You also probably want g_malloc0 which zeroes out the allocated memory, or g_try_malloc0 which returns null on failure rather than aborting the program.

Second error is similar to the first. You just need to cast:

Lastly, you don’t need to make your own plugin for display meta (you can use a probe), but a plugin is more reusable. Be careful though, since there is a lot of boilerplate involved that’s easy to mess up when modifying.

Edit: see I was ninja’d by @jasonpgf2a … Should really have scrolled down.


Thank you @mdegans and @jasonpgf2a ,
Now my all two errors are solved. If you don’t mind can I ask one more problem which I am facing.
I am trying to create sink-bin in my nvdsanalytics pipeline so that I can save h264 encoded output videos. Right now I am able to save single video by directly connecting sink-bin(except queue) elements to the main pipeline -

queue --> nvvidconv --> cap-filter(“video/x-raw, format=I420”) —> encoder(nvv4l2h264enc) --> codecparse(h264parse) --> qmux --> sink (“filesink”)

Source_bin -->streammux --> pgie --> tracker --> nvdsanalytics --> nvvidconv --> nvosd --> streamdemux --> sink_bin

Error I am facing is this : 
0:00:07.014783994  1120 0x7f1ae4013d90 WARN                    v4l2 gstv4l2object.c:2921:gst_v4l2_object_probe_caps_for_format:<nvv4l2decoder0:sink> Could not probe minimum capture size for pixelformat H264
    0:00:07.014796689  1120 0x7f1ae4013d90 WARN                    v4l2 gstv4l2object.c:3035:gst_v4l2_object_get_nearest_size:<nvv4l2decoder0:sink> Unable to try format: Unknown error -1
    0:00:07.014809509  1120 0x7f1ae4013d90 WARN                    v4l2 gstv4l2object.c:2927:gst_v4l2_object_probe_caps_for_format:<nvv4l2decoder0:sink> Could not probe maximum capture size for pixelformat H264
    0:00:07.014874971  1120 0x7f1ae4013d90 WARN                    v4l2 gstv4l2object.c:3035:gst_v4l2_object_get_nearest_size:<nvv4l2decoder0:src> Unable to try format: Unknown error -1

0:00:07.131256250  1120 0x7f1aec011e30 ERROR                   v4l2 gstv4l2object.c:2074:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from
0:00:07.131315844  1120 0x7f1aec011e30 ERROR                   v4l2 gstv4l2object.c:2074:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from

Thanks for helping me.

For DS 5.0 DP: how to integrate nvdsanalytics plugin in C deepstream-app

  1. User need to create analytics bin in /opt/nvidia/deepstream/deepstream-5.0/sources/apps/apps-common/src
  2. Refer deepstream_dsexample.c and similarly create deepstream_nvdsanalytics.c
  3. deepstream_app.h should be modified to add the instance of nvdsanalytics bin and config in the structures
  4. deepstream_config_file_parser.c needs to updated for parsing of nvdsanalytics config from configuration file
  5. deepstream_app.c should be updated for adding the nvdsanalytics bin in the pipeline, ideally location is after the tracker
  6. Create a new cpp file with process_meta function declared with extern “C”, this will parse the meta for nvdsanalytics, refer sample nvdanalytics test app probe call for creation of the function
  7. Add the probe in deepstream_app_main.c after nvdsanalytics bin
  8. Modify Makefile to compile the cpp and deepstream_app_main.c using g++ with -fpermisive flag and link deepstream-app using g++

These are rough steps, but additional modifications in header files required

For DS 5.0 GA we would be adding the support for meta access