How to build custom NvDsInfer API

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) Jetson
• DeepStream Version 6.2
• JetPack Version (valid for Jetson only) 5.0.1
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs) question
• 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)

Hi, I got a question about building a NvDsInfer API.

In NvDsInferObjectDetectionInfo, which is in nvinfer.h, I need to add new value in the struct.
(For example, float expectedIndex).
So I wonder how I can apply this and build custom nvdsinfer.

Thanks.

Yes, you can.
You can find the source code in the directory below and refer to the steps in the README

/opt/nvidia/deepstream/deepstream/sources/libs/nvdsinfer

I get the segmentation fault error with the following change.
From

typedef struct
{
  unsigned int classId;
  unsigned int left;
  unsigned int top;
  unsigned int width;
  unsigned int height;
  float detectionConfidence;
} NvDsInferObjectDetectionInfo;

to

typedef struct
{
  unsigned int classId;
  unsigned int left;
  unsigned int top;
  unsigned int width;
  unsigned int height;
  float detectionConfidence;
  unsigned int expectedIndex;
} NvDsInferObjectDetectionInfo;

Have you recompiled the code? This modification will change the memory layout.

Try make && make install in the following two libraries

/opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-nvinfer

/opt/nvidia/deepstream/deepstream/sources/libs/nvdsinfer

In addition, you should also clear the cache of gstreamer.

sudo /opt/nvidia/deepstream/deepstream/install.sh
1 Like

Thank you so much. I checked there is no segmentation fault after this.
Should I change the pyds bindings if I wanna access the new field(expectedIndex) in probe function?
Cause my application is built in python.

Yes, that’s right, you need to modify this

1 Like

Okay I rebuilt the pyds and installed. All thanks to you.
Maybe this could be the last question.

I tried to get the top, left, width, height, expectedIndex value from obj_meta_list.

batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
        l_frame = batch_meta.frame_meta_list
        while l_frame is not None:
            frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
            obj_meta_list = frame_meta.obj_meta_list
            while obj_meta_list is not None:
                try:
                    obj_meta = pyds.NvDsObjectMeta.cast(obj_meta_list.data)

But when I check the obj_meta.detector_bbox_info there is no expectedIndex.
Seems like detector_bbox_info is NvDsComp_BboxInfo.
How can I access the NvDsInferObjectDetectionInfo in the probe function?

I want to confirm your requirements.

NvDsInferObjectDetectionInfo needs to be filled in by the user and then added to the object meta. Not added by nvinfer.

You can refer to deepstream_ssd_parser.py and ssd_parser.py about the use of NvDsInferObjectDetectionInfo.

1 Like

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