Modifying gst-nvinfer plugin

I need to modify the gst-nvinfer plugin to do some specific things. I’m not having an issue with the code itself, per se. The issue I’m having is compiling and installing the plugin with a custom name.

In gstnvinfer.h:

/* Package and library details required for plugin_init */
define PACKAGE “nvinfer-custom”
define VERSION “1.0”
define LICENSE “Proprietary”
define DESCRIPTION “NVIDIA DeepStreamSDK TensorRT plugin”
define BINARY_PACKAGE “NVIDIA DeepStreamSDK TensorRT plugin”
define URL “http://nvidia.com/

in gstnvinfer.cpp:

static gboolean
nvinfer_plugin_init (GstPlugin * plugin) {
GST_DEBUG_CATEGORY_INIT (gst_nvinfer_debug, “nvinfer-custom”, 0, “nvinfer-custom plugin”);
gst_debug_category_set_threshold (gst_nvinfer_debug, GST_LEVEL_INFO);

return gst_element_register (plugin, “nvinfer-custom”, GST_RANK_PRIMARY, GST_TYPE_NVINFER);
}

I’ve made changes to the code so that it should by seen along side the default nvinfer plugin, but the element is unable to be loaded by gst_element_factory_make, and gst-inspect doesn’t see it either. So I’m not sure what I’m missing exactly.

I’ve also cleared the gstream cache

rm ~/.cache/gstreamer-1.0/registry.x86_64.bin

But that didn’t help either.

Hi,

Maybe, you can verify if GStreamer is registering your modified gst-nvinfer in blacklist

gst-inspect-1.0 --print-blacklist

and you also try to load your modified gst-nvinfer directly

gst-inspect "(nvinfer_library_path)"

Regards
Angel

gst-inspect-1.0 /usr/lib/aarch64-linux-gnu (or x86_64-linux-gnu) /gstreamer-1.0/deepstream/libnvdsgst_infer_custom.so

Is it OK?
Why do you have to change "PACKAGE " name ?

Nothing is blacklisted. But I repeated all my steps again, and now I’m able to pick up my custom version, but the original is no longer registering. I have to clear the GStreamer cache for it to show up, but then once I try to use it, it no longer shows up under gst-inspect.

@ChrisDing See above. I’m now having the opposite problem of my original post.

I’m not changing the package name. I’m creating a modified version of gst-nvinfer, but I also need access to the original gst-nvinfer, so I need them to not conflict.

@ChrisDing
Now when I run gst-inspect:

gst-inspect-1.0 --gst-plugin-path=/opt/nvidia/deepstream/deepstream-4.0/lib/gst-plugins |grep infer

I get the following output:

(gst-plugin-scanner:21645): GLib-GObject-WARNING **: 16:04:49.012: cannot register existing type ‘GstNvInfer’
(gst-plugin-scanner:21645): GLib-CRITICAL **: 16:04:49.013: g_once_init_leave: assertion ‘result != 0’ failed
(gst-plugin-scanner:21645): GStreamer-CRITICAL **: 16:04:49.013: gst_element_register: assertion ‘g_type_is_a (type, GST_TYPE_ELEMENT)’ failed
nvdsgst_infer_custom: nvinfer-custom: NvInfer Custom plugin

It seems my custom plugin is somehow interfering with the original plugin, but I’m unsure why. Any ideas?

I located the source of the issue. I needed to rename the following to a unique name to not cause any conflicts:

  • GstNvInfer
  • GstNvInferClass
  • GstNvInferProcessModeType
  • GstNvInferAllocator
  • GstNvInferAllocatorClass

After renaming these to a unique name for each the errors went away and my program is now working.

2 Likes

Good. Thanks for sharing.