How to use gst-nvinfer

• Hardware Platform (Jetson / GPU)
RTX2080
• DeepStream Version
6.1
• JetPack Version (valid for Jetson only)
• TensorRT Version
8.1
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

I’m using deepstream_infer_tensor_meta_test.cpp and I’d like to use a custom gst-nvinfer instead of gst-nvinfer, how to compile it and use it in my code?

I compiled the sources as it explained in README in gst-infer folder and I generated the libnvdsgst_infer.so and I added it to gst-plugins in the lib folder. When I include the gstnvinfer.h in the deepstream_infer_tensor_meta_test.cpp it shows me this error

/usr/bin/ld: deepstream_infer_tensor_meta_test.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

This is the makefile

################################################################################
# Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
################################################################################

CUDA_VER?=11.7
ifeq ($(CUDA_VER),)
  $(error "CUDA_VER is not set")
endif

APP:= deepstream-infer-tensor-meta-app
CC = g++
TARGET_DEVICE = $(shell gcc -dumpmachine | cut -f1 -d -)

NVDS_VERSION:=6.1

LIB_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/
APP_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/bin/
GST_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/gst-plugins/


SRCS:= $(wildcard *.cpp)
INCS:= $(wildcard *.h)

PKGS:= gstreamer-1.0 opencv4

# CFLAGS:= -fPIC -std=c++11    \
#          -I/opt/nvidia/deepstream/deepstream-6.1/sources/includes \
#          -I /usr/local/cuda-$(CUDA_VER)/include

CFLAGS+= -I /opt/nvidia/deepstream/deepstream-6.1/sources/includes \
		-I /usr/local/cuda-$(CUDA_VER)/include \
    -I /opt/nvidia/deepstream/deepstream-6.1/sources/gst-nvinfer \
    -I /opt/nvidia/deepstream/deepstream-6.1/sources/apps/sample_apps/retina_facereco/test_last/gst-nvinfer-custom

CFLAGS+= $(shell pkg-config --cflags $(PKGS))
LIBS:= $(shell pkg-config --libs $(PKGS))

LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_meta -lnvds_meta -lnvds_inferutils -lnvds_utils -lm \
         -lnvbufsurface -lnvbufsurftransform -lnvdsgst_helper -lnvds_batch_jpegenc  \
        -L$(GST_INSTALL_DIR) -lnvdsgst_infer \
       -L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart  \
       -lcuda -Wl,-rpath,$(LIB_INSTALL_DIR)

ifeq ($(TARGET_DEVICE),aarch64)
  CFLAGS+= -DPLATFORM_TEGRA
  SRCS+=/opt/nvidia/deepstream/deepstream-6.1/sources/apps/sample_apps/retina_facereco/nvdsinfer_customparser/nvdsparse_retinaface.cpp
else
  LIBS+= -L$(LIB_INSTALL_DIR) -lnvds_infercustomparser      

endif

OBJS:= $(SRCS:.cpp=.o)

all: $(APP)
debug: CFLAGS+= -DDEBUG -g
debug: CXXFLAGS+= -DDEBUG -g
debug: CCFLAGS+= -DDEBUG -g
debug: $(APP)

%.o: %.cpp $(INCS) Makefile
	$(CC) -c -o $@ $(CFLAGS) $<

$(APP): $(OBJS) Makefile
	$(CC) -o $(APP) $(OBJS) $(LIBS)  

install: $(APP)
	cp -rv $(APP) $(APP_INSTALL_DIR)

clean:
	rm -rf $(OBJS) $(APP)

In the makefile I specified the -L$(GST_INSTALL_DIR) -lnvdsgst_infer \ which is libnvdsgst_infer.so

What is the issue is it a linker problem or symbolic link ?

All the DeepStream plugins are in /opt/nvidia/deepstream/deepstream/lib/gst-plugins folder. Please put the plugin you built here to replace the prebuilt one.

What do you mean by put it here?
So my plugin folder called gst-nvinfer-custom should I replace the gst-nvinfer which is in gst-plugins and that’s all?

The folder of the source code is not important. Seems you are still generating “libnvdsgst_infer.so” which is the same as the original plugin library, and I think you are just modifying some parts of the source code under /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-nvinfer, so it is still the same plugin, the installation folder is /opt/nvidia/deepstream/deepstream/lib/gst-plugins, you need to use your library to replace the original one. GStreamer registry only identifies elements by names. Plugin Writer's Guide The name is the same, they are the same. You are not creating a new plugin. Please learn the basic GStreamer knowledge by yourself.

How would I do that?

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

It has been mentioned

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