Custom Deepstream Plugin

• Jetson Orin 64GB Dev Kit
• Deepstream 6.2
• JetPack Version 5.1
• TensorRT 8.5.2.2

I am creating a custom plugin and I am basing it off of the gstdsexample code here: (/opt/nvidia/deepstream/deepstream-6.2/sources/gst-plugins/gst-dsexample). In my custom deepstream plugin I am attempting to create a PIP(Picture-in-Picture) for digital enhancement around a cropped section of an object. I am using a CMakeLists.txt where the parent CMakeLists.txt defines:

set(GST_INSTALL_DIR "/opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/lib/gst-plugins/")

So when I build my custom pip plugin it is installed in the directory as libnvdsgst_pip.so. The issue I am facing is that it doesn’t seem to be able to find the pip element this plugin should be creating. In my deepstream_app.cpp(which is based off of deepstream-app), inside of gboolean create_pipeline(...), I followed suite with what you guys were doing with the dsexample and created the following check:

// Add PIP(Picture-in-Picture) element
  if (config->pip_config.enable) {
    // Create pip element bin and set properties
    if (!create_pip_bin(&config->pip_config,
                              &pipeline->pip_bin)) {
      g_print("Unable to create a PIP Element!\n");
      goto done;
    }
    // Add pip bin to instance bin
    gst_bin_add(GST_BIN(pipeline->pipeline), pipeline->pip_bin.bin);

    // Link this bin to the last element in the bin
    NVGSTDS_LINK_ELEMENT(pipeline->pip_bin.bin, last_elem);

    // Set this bin as the last element
    last_elem = pipeline->pip_bin.bin;

    g_print("Successfully created PIP Element!\n");
  }

However, this fails on the create_pip_bin which is defined in the deepstream_pip.c file attached. Specifically it fails to create the PIP element on this line:

bin->elem_pip = gst_element_factory_make(NVDS_ELEM_PIP_ELEMENT, "pip");
  if (!bin->elem_pip) {
    NVGSTDS_ERR_MSG_V("Failed to create 'pip'");
    goto done;
  }

Any ideas on what the issue could be for it not being able to create the pip element?

One thing I noticed in the gstdsexample.cpp file at the bottom was this line:

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
    GST_VERSION_MINOR,
    nvdsgst_dsexample,
    DESCRIPTION, dsexample_plugin_init, DS_VERSION, LICENSE, BINARY_PACKAGE, URL)

You have the DS_VERSION which I don’t see defined anywhere. So, in my code I am using the VERSION defined in deepstream_pip.h. Could this be the issue?

Thanks

CMakeLists.txt (1.2 KB)
pip.cpp (25.5 KB)
pip.h (3.1 KB)
deepstream_pip.h (720 Bytes)
deepstream_pip.c (2.3 KB)

The library file name in GST_PLUGIN_DEFINE does not match your .so file. You need to change this:

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
    GST_VERSION_MINOR,
    nvdsgst_dsexample,
    DESCRIPTION, dsexample_plugin_init, DS_VERSION, LICENSE, BINARY_PACKAGE, URL)

to this:

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
    GST_VERSION_MINOR,
    nvdsgst_pip,
    DESCRIPTION, dsexample_plugin_init, DS_VERSION, LICENSE, 
BINARY_PACKAGE, URL)

There may be other issues as well.

1 Like

@hunter.norman Thanks for the speedy reply but if you look at the attached pip.cpp(which is basically a copy of gstdsexample.cpp) I have it defined exactly the way you have above with of course with the change of the pip_plugin_init into the parameters as well. The code snippet I was referring to above was directly from gstdsexample.cpp, I was just wanting to know where the DS_VERSION variable they are using is coming from and if it matters?

It comes from the Makefile included with gst-dsexample, specifically this part:

CFLAGS+= -fPIC -DDS_VERSION=\"6.3.0\" \
	 -I /usr/local/cuda-$(CUDA_VER)/include \
	 -I ../../includes

What is the output of gst-inspect-1.0 pip on your system?

1 Like

Ahh I see, good find! gst-inspect-1.0 pip gives
No such element or plugin ‘pip’

So it must not be installing it correctly when I build and install it?

Correct. Try to locate the libnvdsgst_pip.so file on your system. If it is in the correct place but still not found by gst-inspect-1.0, then it means your are not defining the name correctly. You can try setting the env variable GST_PLUGIN_PATH manually as well to ensure that gst-inspect-1.0 searches in a certain folder for plugins.

1 Like

Thanks for your help!

So it’s found here:

/opt/nvidia/deepstream/deepstream-6.2/lib/gst-plugins/libnvdsgst_pip.so

And I have found the issue:

(gst-plugin-scanner:1747073): GStreamer-WARNING **: 19:51:15.525: Failed to load plugin '/opt/nvidia/deepstream/deepstream-6.2/lib/gst-plugins/libnvdsgst_pip.so': /opt/nvidia/deepstream/deepstream-6.2/lib/gst-plugins/libnvdsgst_pip.so: undefined symbol: NvBufSurfaceSyncForCpu

Looks to be some issue with not being able to find NvBufSurfaceSyncForCpu.

Thanks @hunter.norman! Without your help I wouldn’t have been able to solve this as easily!

Looks like for the above issue my CMakeLists.txt was just missing some needed libraries for linkage!

I really appreciate the help!

1 Like

You’re welcome :)

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