GStreamer Plugin Details

Gst-nvinfer

The Gst-nvinfer plugin does inferencing on input data using NVIDIA® TensorRT™.
The plugin accepts batched NV12/RGBA buffers from upstream. The NvDsBatchMeta structure must already be attached to the Gst Buffers.
The low-level library (libnvds_infer) operates on any of INT8 RGB, BGR, or GRAY data with dimension of Network Height and Network Width.
The Gst-nvinfer plugin performs transforms (format conversion and scaling), on the input frame based on network requirements, and passes the transformed data to the low-level library.
The low-level library preprocesses the transformed frames (performs normalization and mean subtraction) and produces final float RGB/BGR/GRAY planar data which is passed to the TensorRT engine for inferencing. The output type generated by the low-level library depends on the network type.
The pre-processing function is:
Where:
x is the input pixel value. It is an int8 with range [0,255].
mean is the corresponding mean value, read either from the mean file or as offsets[c], where c is the channel to which the input pixel belongs, and offsets is the array specified in the configuration file. It is a float.
net-scale-factor is the pixel scaling factor specified in the configuration file. It is a float.
y is the corresponding output pixel value. It is a float.
Gst-nvinfer currently works on the following type of networks:
Multi-class object detection
Multi-label classification
Segmentation (semantic)
Instance Segmentation
The Gst-nvinfer plugin can work in two modes:
Primary mode: Operates on full frames
Secondary mode: Operates on objects added in the meta by upstream components
When the plugin is operating as a secondary classifier along with the tracker, it tries to improve performance by avoiding re-inferencing on the same objects in every frame. It does this by caching the classification output in a map with the object’s unique ID as the key. The object is inferred upon only when it is first seen in a frame (based on its object ID) or when the size (bounding box area) of the object increases by 20% or more. This optimization is possible only when the tracker is added as an upstream element.
Detailed documentation of the TensorRT interface is available at:
The plugin supports the IPlugin interface for custom layers. Refer to section IPlugin Interface for details.
The plugin also supports the interface for custom functions for parsing outputs of object detectors and initialization of non-image input layers in cases where there is more than one input layer.
Refer to sources/includes/nvdsinfer_custom_impl.h for the custom method implementations for custom models.
A screenshot of a cell phone Description automatically generated
Downstream components receive a Gst Buffer with unmodified contents plus the metadata created from the inference output of the Gst-nvinfer plugin.
The plugin can be used for cascaded inferencing. That is, it can perform primary inferencing directly on input data, then perform secondary inferencing on the results of primary inferencing, and so on. See the sample application deepstream-test2 for more details.

Inputs and Outputs

This section summarizes the inputs, outputs, and communication facilities of the Gst-nvinfer plugin.
Inputs
Gst Buffer
NvDsBatchMeta (attaching NvDsFrameMeta)
Caffe Model and Caffe Prototxt
ONNX
UFF file
TLT Encoded Model and Key
Offline: Supports engine files generated by Transfer Learning Toolkit SDK Model converters
Layers: Supports all layers supported by TensorRT, see:
Control parameters: Gst-nvinfer gets control parameters from a configuration file. You can specify this by setting the property config-file-path. For details, see Gst-nvinfer File Configuration Specifications. Other control parameters that can be set through GObject properties are:
Batch size
Inference interval
Attach inference tensor outputs as buffer metadata
Attach instance mask output as in object metadata
The parameters set through the GObject properties override the parameters in the Gst-nvinfer configuration file.
Outputs
Gst Buffer
Depending on network type and configured parameters, one or more of:
NvDsObjectMeta
NvDsClassifierMeta
NvDsInferSegmentationMeta
NvDsInferTensorMeta

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvinfer plugin
Feature
Description
Release
Explicit Full Dimension Network Support
DS 5.0
Non-maximum Suppression (NMS)
New bounding box clustering algorithm.
DS 5.0
On-the-fly model update (Engine file only)
Update the model-engine-file on-the-fly in a running pipeline.
DS 5.0
Configurable frame scaling params
Configurable options to select the compute hardware and the filter to use while scaling frame/object crops to network resolution
DS 5.0
Transfer-Learning-Toolkit encoded model support
DS 4.0
Gray input model support
Support for models with single channel gray input
DS 4.0
Tensor output as meta
Raw tensor output is attached as meta data to Gst Buffers and flowed through the pipeline
DS 4.0
Segmentation model
Supports segmentation model
DS 4.0
Maintain input aspect ratio
Configurable support for maintaining aspect ratio when scaling input frame to network resolution
DS 4.0
Custom cuda engine creation interface
Interface for generating CUDA engines from TensorRT INetworkDefinition and IBuilder APIs instead of model files
DS 4.0
Caffe Model support
DS 2.0
UFF Model support
DS 3.0
ONNX Model support
DS 3.0
Multiple modes of operation
Support for cascaded inferencing
DS 2.0
Asynchronous mode of operation for secondary inferencing
Infer asynchronously for secondary classifiers
DS 2.0
Grouping using CV::Group rectangles
For detector bounding box clustering
DS 2.0
Configurable batch-size processing
User can configure batch size for processing
DS 2.0
No Restriction on number of output blobs
Supports any number of output blobs
DS 3.0
Configurable number of detected classes (detectors)
Supports configurable number of detected classes
DS 3.0
Support for Classes: configurable (> 32)
Supports any number of classes
DS 3.0
Application access to raw inference output
Application can access inference output buffers for user specified layer
DS 3.0
Support for single shot detector (SSD)
DS 3.0
Secondary GPU Inference Engines (GIEs) operate as detector on primary bounding box
Supports secondary inferencing as detector
DS 2.0
Multiclass secondary support
Supports multiple classifier network outputs
DS 2.0
Grouping using DBSCAN
For detector bounding box clustering
DS 3.0
Loading an external lib containing IPlugin implementation for custom layers (IPluginCreator & IPluginFactory)
Supports loading (dlopen()) a library containing IPlugin implementation for custom layers
DS 3.0
Multi GPU
Select GPU on which we want to run inference
DS 2.0
Detection width height configuration
Filter out detected objects based on min/max object size threshold
DS 2.0
Allow user to register custom parser
Supports final output layer bounding box parsing for custom detector network
DS 2.0
Bounding box filtering based on configurable object size
Supports inferencing in secondary mode objects meeting min/max size threshold
DS 2.0
Configurable operation interval
Interval for inferencing (number of batched buffers skipped)
DS 2.0
Select Top and bottom regions of interest (RoIs)
Removes detected objects in top and bottom areas
DS 2.0
Operate on Specific object type (Secondary mode)
Process only objects of define classes for secondary inferencing
DS 2.0
Configurable blob names for parsing bounding box (detector)
Support configurable names for output blobs for detectors
DS 2.0
Allow configuration file input
Support configuration file as input (mandatory in DS 3.0)
DS 2.0
Allow selection of class id for operation
Supports secondary inferencing based on class ID
DS 2.0
Support for Full Frame Inference: Primary as a classifier
Can work as classifier as well in primary mode
DS 2.0
Multiclass secondary support
Support multiple classifier network outputs
DS 2.0
Secondary GIEs operate as detector on primary bounding box
Support secondary inferencing as detector
DS 2.0
Supports FP16, FP32 and INT8 models
FP16 and INT8 are platform dependent
DS 2.0
Supports TensorRT Engine file as input
 
DS 2.0
Inference input layer initialization
Initializing non-video input layers in case of more than one input layers
DS 3.0
Support for FasterRCNN
DS 3.0
Support for Yolo detector (YoloV3/V3-tiny/V2/V2-tiny)
DS 4.0
Support for yolov3-spp detector
DS 5.0
Support Instance segmentation with MaskRCNN
Support for instance segmentation using MaskRCNN. It includes output parser and attach mask in object metadata.
DS 5.0

Gst-nvinfer File Configuration Specifications

The Gst-nvinfer configuration file uses a “Key File” format described in:
The [property] group configures the general behavior of the plugin. It is the only mandatory group.
The [class-attrs-all] group configures detection parameters for all classes.
The [class-attrs-<class-id>] group configures detection parameters for a class specified by <class-id>. For example, the [class-attrs-23] group configures detection parameters for class ID 23. This type of group has the same keys as [class-attrs-all].
The following two tables respectively describe the keys supported for [property] groups and [class-attrs-…] groups.
Gst-nvinfer plugin, [property] group, supported keys
Property
Meaning
Type and Range
Example
Notes
Network Types/ Applicable to GIEs (Primary/Secondary)
num-detected-classes
Number of classes detected by the network
Integer, >0
num-detected-classes=91
Detector
Both
net-scale-factor
Pixel normalization factor
Float, >0.0
net-scale-factor=0.031
All
Both
model-file
Pathname of the caffemodel file. Not required if model-engine-file is used
String
model-file=/home/ubuntu/model.caffemodel
All
Both
proto-file
Pathname of the prototxt file. Not required if model-engine-file is used
String
proto-file=/home/ubuntu/model.prototxt
All
Both
int8-calib-file
Pathname of the INT8 calibration file for dynamic range adjustment with an FP32 model
String
int8-calib-file=/home/ubuntu/int8_calib
All
Both
batch-size
Number of frames or objects to be inferred together in a batch
Integer, >0
batch-size=30
All
Both
model-engine-file
Pathname of the serialized model engine file
String
model-engine-file=/home/ubuntu/model.engine
All
Both
uff-file
Pathname of the UFF model file
String
uff-file=/home/ubuntu/model.uff
All
Both
onnx-file
Pathname of the ONNX model file
String
onnx-file=/home/ubuntu/model.onnx
All
Both
enable-dbscan
Indicates whether to use DBSCAN or the OpenCV groupRectangles() function for grouping detected objects.
DEPRECATED. Use cluster-mode instead.
Boolean
enable-dbscan=1
Detector
Both
labelfile-path
Pathname of a text file containing the labels for the model
String
labelfile-path=/home/ubuntu/model_labels.txt
Detector & classifier
Both
mean-file
Pathname of mean data file (PPM format)
String
mean-file=/home/ubuntu/model_meanfile.ppm
All
Both
gie-unique-id
Unique ID to be assigned to the GIE to enable the application and other elements to identify detected bounding boxes and labels
Integer, >0
gie-unique-id=2
All
Both
operate-on-gie-id
Unique ID of the GIE on whose metadata (bounding boxes) this GIE is to operate on
Integer, >0
operate-on-gie-id=1
All
Both
operate-on-class-ids
Class IDs of the parent GIE on which this GIE is to operate on
Semicolon delimited integer array
operate-on-class-ids=1;2
Operates on objects with class IDs 1, 2 generated by parent GIE
All
Both
interval
Specifies the number of consecutive batches to be skipped for inference
Integer, >0
interval=1
All
Primary
input-object-min-width
Secondary GIE infers only on objects with this minimum width
Integer, ≥0
input-object-min-width=40
All
Secondary
input-object-min-height
Secondary GIE infers only on objects with this minimum height
Integer, ≥0
input-object-min-height=40
All
Secondary
input-object-max-width
Secondary GIE infers only on objects with this maximum width
Integer, ≥0
input-object-max-width=256
0 disables the threshold
All
Secondary
input-object-max-height
Secondary GIE infers only on objects with this maximum height
Integer, ≥0
input-object-max-height=256
0 disables the threshold
All
Secondary
uff-input-dims
DEPRECATED. Use infer-dims and uff-input-order instead.
 
Dimensions of the UFF model
 
channel;
height;
width;
input-order
All integers, ≥0
input-dims=3;224;224;0
Possible values for input-order are:
0: NCHW
1: NHWC
All
Both
network-mode
Data format to be used by inference
Integer
0: FP32
1: INT8
2: FP16
network-mode=0
All
Both
offsets
Array of mean values of color components to be subtracted from each pixel. Array length must equal the number of color components in the frame. The plugin multiplies mean values by net-scale-factor.
Semicolon delimited float array,
all values ≥0
offsets=77.5;21.2;11.8
All
Both
output-blob-names
Array of output layer names
Semicolon delimited string array
For detector:
output-blob-names=coverage;bbox
For multi-label classifiers:
output-blob-names=coverage_attrib1;coverage_attrib2
All
Both
parse-bbox-instance-mask-func-name
Name of the custom instance segmentation parsing function. It is mandatory for instance segmentation network as there is no internal function.
String
parse-bbox-instance-mask-func-name=NvDsInferParseCustomMrcnnTLT
Instance Segmentation Primary
custom-lib-path
Absolute pathname of a library containing custom method implementations for custom models
String
custom-lib-path=/home/ubuntu/libresnet_custom_impl.so
All
Both
model-color-format
Color format required by the model
Integer
0: RGB
1: BGR
2: GRAY
model-color-format=0
All
Both
classifier-async-mode
Enables inference on detected objects and asynchronous metadata attachments. Works only when tracker-ids are attached. Pushes buffer downstream without waiting for inference results. Attaches metadata after the inference results are available to next Gst Buffer in its internal queue.
Boolean
classifier-async-mode=1
Classifier
Secondary
process-mode
Mode (primary or secondary) in which the element is to operate on
Integer
1=Primary
2=Secondary
gie-mode=1
All
Both
classifier-threshold
Minimum threshold label probability. The GIE outputs the label having the highest probability if it is greater than this threshold
Float, ≥0
classifier-threshold=0.4
Classifier
Both
uff-input-blob-name
Name of the input blob in the UFF file
String
uff-input-blob-name=Input_1
All
Both
secondary-reinfer-interval
Re-inference interval for objects, in frames
Integer, ≥0
secondary-reinfer-interval=15
Classifier
Secondary
output-tensor-meta
Gst-nvinfer attaches raw tensor output as Gst Buffer metadata.
Boolean
output-tensor-meta=1
All
Both
output-instance-mask
Gst-nvinfer attaches instance mask output in object metadata.
Boolean
output-instance-mask=1
Instance Segmentation Primary
enable-dla
Indicates whether to use the DLA engine for inferencing.
Note: DLA is supported only on NVIDIA® Jetson AGX Xavier™. Currently work in progress.
Boolean
enable-dla=1
All
Both
use-dla-core
DLA core to be used.
Note: Supported only on Jetson AGX Xavier. Currently work in progress.
Integer, ≥0
use-dla-core=0
All
Both
network-type
Type of network
Integer
0: Detector
1: Classifier
2: Segmentation
3: Instance Segmentation
network-type=1
All
Both
maintain-aspect-ratio
Indicates whether to maintain aspect ratio while scaling input.
Boolean
maintain-aspect-ratio=1
All
Both
parse-classifier-func-name
Name of the custom classifier output parsing function. If not specified, Gst-nvinfer uses the internal parsing function for softmax layers.
String
parse-classifier-func-name=parse_bbox_softmax
Classifier
Both
custom-network-config
Pathname of the configuration file for custom networks available in the custom interface for creating CUDA engines.
String
custom-network-config=/home/ubuntu/network.config
All
Both
tlt-encoded-model
Pathname of the Transfer Learning Toolkit (TLT) encoded model.
String
tlt-encoded-model=/home/ubuntu/model.etlt
All
Both
tlt-model-key
Key for the TLT encoded model.
String
tlt-model-key=abc
All
Both
segmentation-threshold
Confidence threshold for the segmentation model to output a valid class for a pixel. If confidence is less than this threshold, class output for that pixel is −1.
Float, ≥0.0
segmentation-threshold=0.3
Segmentation, Instance segmentation
Both
workspace-size
Workspace size to be used by the engine, in MB
Integer, >0
workspace-size=45
All
Both
force-implicit-batch-dim
When a network supports both implicit batch dimension and full dimension, force the implicit batch dimension mode.
Boolean
force-implicit-batch-dim=1
All
Both
infer-dims
Binding dimensions to set on the image input layer.
channel;
height;
width
infer-dims=3;224;224
All
Both
uff-input-order
UFF input layer order
Integer
0: NCHW
1: NHWC
2: NC
uff-input-order=1
All
Both
engine-create-func-name
Name of the custom TensorRT CudaEngine creation function. Refer to the “Custom Model Implementation Interface” section for details
String
engine-create-func-name=NvDsInferYoloCudaEngineGet
All
Both
cluster-mode
Clustering algorithm to use. Refer to the next table for configuring the algorithm specific parameters.
Integer
0: OpenCV groupRectangles()
1: DBSCAN
2: Non Maximum Suppression
3: DBSCAN + NMS Hybrid
4:No clustering
cluster-mode=2
Detector
Both
cluster-mode=4 for instance segmentation
filter-out-class-ids
Filter out detected objects belonging to specified class-ids
Semicolon delimited integer array
filter-out-class-ids=1;2
Detector
Both
scaling-filter
The filter to use for scaling frames / object crops to network resolution
Integer, refer to enum NvBufSurfTransform_Inter in nvbufsurftransform.h for valid values
scaling-filter=1
All
Both
scaling-compute-hw
Compute hardware to use for scaling frames / object crops to network resolution
Integer
0: Platform default – GPU (dGPU), VIC (Jetson)
1: GPU
2: VIC (Jetson only)
scaling-compute-hw=2
All
Both
output-io-formats
Specifies the data type and order for bound output layers. For layers not specified, defaults to FP32 and CHW
Semi-colon separated list of format.
<output-layer1-name>:<data-type>:<order>;<output-layer2-name>:<data-type>:<order>
 
data-type should be one of
[fp32, fp16, int32, int8]
 
order should be one of [chw, chw2, chw4, hwc8, chw16, chw32]
output-io-formats=conv2d_bbox:fp32:chw;conv2d_cov/Sigmoid:fp32:chw
All
Both
Layer-device-precision
Specifies the device type and precision for any layer in the network
Semi-colon separated list of format.
<layer1-name>:<precision>:<device-type>;<layer2-name>:<precision>:<device-type>;
 
precision should be one of
[fp32, fp16, int8]
 
Device-type should be one of [gpu, dla]
layer-device-precision=output_cov/Sigmoid:fp32:gpu;output_bbox/BiasAdd:fp32:gpu;
All
Both
 
Gst-nvinfer plugin, [class-attrs-...] groups, supported keys
Name
Description
Type and Range
Example
Notes
(Primary/Secondary)
threshold
Detection threshold
Float, ≥0
threshold=0.5
Object detector
Both
pre-cluster-threshold
Detection threshold to be applied prior to clustering operation
Float, ≥0
pre-cluster-threshold=0.5
Object detector
Both
Post-cluster-threshold
Detection threshold to be applied post clustering operation
Float, ≥0
post-cluster-threshold=0.5
Object detector
Both
eps
Epsilon values for OpenCV grouprectangles() function and DBSCAN algorithm
Float, ≥0
eps=0.2
Object detector
Both
group-threshold
Threshold value for rectangle merging for OpenCV grouprectangles() function
Integer, ≥0
group-threshold=1
0 disables the clustering functionality
Object detector
Both
minBoxes
Minimum number of points required to form a dense region for DBSCAN algorithm
Integer, ≥0
minBoxes=1
0 disables the clustering functionality
Object detector
Both
dbscan-min-score
Minimum sum of confidence of all the neighbors in a cluster for it to be considered a valid cluster.
Float, ≥0
dbscan-min-score=0.7
Object detector
Both
nms-iou-threshold
Maximum IOU score between two proposals after which the proposal with the lower confidence will be rejected.
Float, ≥0
nms-iou-threshold=0.2
Object detector
Both
roi-top-offset
Offset of the RoI from the top of the frame. Only objects within the RoI are output.
Integer, ≥0
roi-top-offset=200
Object detector
Both
roi-bottom-offset
Offset of the RoI from the bottom of the frame. Only objects within the RoI are output.
Integer, ≥0
roi-bottom-offset=200
Object detector
Both
detected-min-w
Minimum width in pixels of detected objects to be output by the GIE
Integer, ≥0
detected-min-w=64
Object detector
Both
detected-min-h
Minimum height in pixels of detected objects to be output by the GIE
Integer, ≥0
detected-min-h=64
Object detector
Both
detected-max-w
Maximum width in pixels of detected objects to be output by the GIE
Integer, ≥0
detected-max-w=200
0 disables the property
Object detector
Both
detected-max-h
Maximum height in pixels of detected objects to be output by the GIE
Integer, ≥0
detected-max-h=200
0 disables the property
Object detector
Both
topk
Keep only top K objects with highest detection scores.
Integer, ≥0.
-1 to disable
topk=10
Object detector
Both

Gst Properties

The values set through Gst properties override the values of properties in the configuration file. The application does this for certain properties that it needs to set programmatically.
The following table describes the Gst-nvinfer plugin’s Gst properties.
Gst-nvinfer plugin, Gst properties
Property
Meaning
Type and Range
Example
Notes
config-file-path
Absolute pathname of configuration file for the Gst-nvinfer element
String
config-file-path=config_infer_primary.txt
process-mode
Infer Processing Mode
1=Primary Mode
2=Secondary Mode
Integer, 1 or 2
process-mode=1
unique-id
Unique ID identifying metadata generated by this GIE
Integer,
0 to 4,294,967,295
unique-id=1
infer-on-gie-id
See operate-on-gie-id in the configuration file table
Integer,
0 to 4,294,967,295
infer-on-gie-id=1
operate-on-class-ids
See operate-on-class-ids in the configuration file table
An array of colon- separated integers (class-ids)
operate-on-class-ids=1:2:4
filter-out-class-ids
See filter-out-class-ids in the configuration file table
Semicolon delimited integer array
filter-out-class-ids=1;2
model-engine-file
Absolute pathname of the pre-generated serialized engine file for the mode
String
model-engine-file=model_b1_fp32.engine
batch-size
Number of frames/objects to be inferred together in a batch
Integer,
1 – 4,294,967,295
batch-size=4
Interval
Number of consecutive batches to be skipped for inference
Integer, 0 to 32
interval=0
gpu-id
Device ID of GPU to use for pre-processing/inference (dGPU only)
Integer,
0-4,294,967,295
gpu-id=1
raw-output-file-write
Pathname of raw inference output file
Boolean
raw-output-file-write=1
raw-output-generated-callback
Pointer to the raw output generated callback function
Pointer
Cannot be set through gst-launch
raw-output-generated-userdata
Pointer to user data to be supplied with raw-output-generated-callback
Pointer
Cannot be set through gst-launch
output-tensor-meta
Indicates whether to attach tensor outputs as meta on GstBuffer.
Boolean
output-tensor-meta=0
output-instance-mask
Gst-nvinfer attaches instance mask output in object metadata.
Boolean
output-instance-mask=1

Tensor Metadata

The Gst-nvinfer plugin can attach raw output tensor data generated by a TensorRT inference engine as metadata. It is added as an NvDsInferTensorMeta in the frame_user_meta_list member of NvDsFrameMeta for primary (full frame) mode, or in the obj_user_meta_list member of NvDsObjectMeta for secondary (object) mode.
To read or parse inference raw tensor data of output layers
1. Enable property output-tensor-meta or enable the same-named attribute in the configuration file for the Gst-nvinfer plugin.
2. When operating as primary GIE, NvDsInferTensorMeta is attached to each frame’s (each NvDsFrameMeta object’s) frame_user_meta_list. When operating as secondary GIE, NvDsInferTensorMeta is attached to each each NvDsObjectMeta object’s obj_user_meta_list.
Metadata attached by Gst-nvinfer can be accessed in a GStreamer pad probe attached downstream from the Gst-nvinfer instance.
3. The NvDsInferTensorMeta object’s metadata type is set to NVDSINFER_TENSOR_OUTPUT_META. To get this metadata you must iterate over the NvDsUserMeta user metadata objects in the list referenced by frame_user_meta_list or obj_user_meta_list.
For more information about Gst-infer tensor metadata usage, see the source code in sources/apps/sample_apps/deepstream_infer_tensor_meta-test.cpp, provided in the DeepStream SDK samples.

Segmentation Metadata

The Gst-nvinfer plugin attaches the output of the segmentation model as user meta in an instance of NvDsInferSegmentationMeta with meta_type set to NVDSINFER_SEGMENTATION_META. The user meta is added to the frame_user_meta_list member of NvDsFrameMeta for primary (full frame) mode, or the obj_user_meta_list member of NvDsObjectMeta for secondary (object) mode.
For guidance on how to access user metadata, see User/Custom Metadata Addition Inside NvDsMatchMeta and Tensor Metadata, above.

Gst-nvinferserver

The Gst-nvinferserver plugin does inferencing on input data using NVIDIA® Triton Inference Server (previously called TensorRT Inference Server) Release 1.12.0 corresponding to NGC container 20.03. Refer to https://docs.nvidia.com/deeplearning/triton-inference-server/user-guide/docs/index.html for Triton Inference Server (Triton) documentation.
The plugin accepts batched NV12/RGBA buffers from upstream. The NvDsBatchMeta structure must already be attached to the Gst Buffers.
The low-level library (libnvds_infer_server) operates on any of NV12 or RGBA buffers.
The Gst-nvinferserver plugin passes the input batched buffers to the low-level library and waits for the results to be available. Meanwhile, it keeps queuing input buffers to the low-level library as they are received. Once the results are available from the low-level library, the plugin translates and attaches the results back in to Gst-buffer for downstream plugins.
The low-level library preprocesses the transformed frames (performs color conversion and scaling, normalization and mean subtraction) and produces final FP32/FP16/INT8/UINT8/INT16/UINT16/INT32/UINT32 RGB/BGR/GRAY planar/packed data which is passed to the Triton for inferencing. The output type generated by the low-level library depends on the network type.
The pre-processing function is:
Where:
x is the input pixel value. It is an uint8 with range [0,255].
mean is the corresponding mean value, read either from the mean file or as offsets[c], where c is the channel to which the input pixel belongs, and offsets is the array specified in the configuration file. It is a float.
net-scale-factor is the pixel scaling factor specified in the configuration file. It is a float.
y is the corresponding output pixel value. It can be of type float / half / int8 / uint8 / int16 / uint16 / int32 / uint32.
Take specific example for uint8 to int8 conversion. set netscalefactor = 1.0 and mean = [128, 128, 128]. then the function is as such
Gst-nvinferserver currently works on the following type of networks:
Multi-class object detection
Multi-label classification
Segmentation
The Gst-nvinferserver plugin can work in two modes:
Primary mode: Operates on full frames
Secondary mode: Operates on objects added in the meta by upstream components
When the plugin is operating as a secondary classifier in async mode along with the tracker, it tries to improve performance by avoiding re-inferencing on the same objects in every frame. It does this by caching the classification output in a map with the object’s unique ID as the key. The object is inferred upon only when it is first seen in a frame (based on its object ID) or when the size (bounding box area) of the object increases by 20% or more. This optimization is possible only when the tracker is added as an upstream element.
Detailed documentation of the Triton Inference Server is available at:
The plugin supports Triton features along with multiple deep-learning frameworks such as TensorRT, TensorFlow (GraphDef / SavedModel), ONNX and PyTorch on Tesla platforms. On Jetson, it also supports TensorRT and TensorFlow (GraphDef / SavedModel). Tensorflow and ONNX can be configured with TensorRT acceleration. For details, see framework-Specific Optimization.
The plugin requires a configurable model repository root directory path where all the models need to reside. All the plugin instances in a single process must share the same model root. For details, see Model Repository. Each model also needs a specific config.pbtxt file in its subdirectory. For details, see Model Configuration.
The plugin supports Triton ensemble mode in the case users need do preprocessing or postprocessing with Triton custom backend.
The plugin also supports the interface for custom functions for parsing outputs of object detectors, classifiers, and initialization of non-image input layers in cases where there is more than one input layer.
Refer to sources/includes/nvdsinfer_custom_impl.h for the custom method implementations for custom models.
A screenshot of a cell phone Description automatically generated
Downstream components receive a Gst Buffer with unmodified contents plus the metadata created from the inference output of the Gst-nvinferserver plugin.
The plugin can be used for cascaded inferencing. That is, it can perform primary inferencing directly on input data, then perform secondary inferencing on the results of primary inferencing, and so on. This is similar with Gst-nvinfer, see more details in Gst-nvinfer.

Inputs and Outputs

This section summarizes the inputs, outputs, and communication facilities of the Gst-nvinferserver plugin.
Inputs
Gst Buffer
NvDsBatchMeta (attaching NvDsFrameMeta)
Model repository directory path (model_repo.root)
Runtime model file with config.pbtxt file in model repository
Control parameters:
Gst-nvinferserver gets control parameters from a configuration file. You can specify this by setting the property config-file-path. For details, see Gst-nvinferserver File Configuration Specifications. Other control parameters that can be set through GObject properties are:
Batch size
Process mode
Unique id
Inference on GIE id and operate on class ids [secondary mode only]
Inference interval
Raw output generated callback function
The parameters set through the GObject properties override the parameters in the Gst-nvinferserver configuration file.
Outputs
Gst Buffer
Depending on network type and configured parameters, one or more of:
NvDsObjectMeta
NvDsClassifierMeta
NvDsInferSegmentationMeta
NvDsInferTensorMeta

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvinferserver plugin
Feature
dGPU
Jetson
Release
Gst-nvinferserver Running on Host
No
Yes
DS 5.0
Running on Docker Image
Yes
No
DS 5.0
DS Preprocessing: Network input format: RGB/BGR/Gray
Yes
Yes
DS 5.0
DS Preprocessing: Network input data types FP32/FP16/UINT8/INT8/UINT16/INT16/UINT32/INT32
Yes
Yes
DS 5.0
DS Preprocessing: Network input tensor orders
NCHW / NHWC
Yes
Yes
DS 5.0
Mem: Cuda(GPU) buf-sharing for Input Tensors
Yes
Yes
DS 5.0
Mem: Cuda Memory (GPU / CPU-pinned) for output tensors
Yes
Yes
DS 5.0
Backend: TensorRT runtime (plan engine file)
Yes
Yes
DS 5.0
Backend: Tensorflow Runtime CPU/GPU (graphdef/savedmodel)
Yes
Yes
DS 5.0
Backend: Tensorflow Runtime with TF-TRT acceleration
Yes
Yes
DS 5.0
Backend: ONNX Runtime
Yes
No
DS 5.0
Backend: ONNX Runtime with ONNX-TRT acceleration
Yes
No
DS 5.0
Backend: Pytorch Runtime
Yes
No
DS 5.0
[deprecated, will be removed in future version]
Backend: Caffe2 Runtime
Yes
(very few tests)
No
DS 5.0
Postprocessing: DS Detection / Classification/ Segmentation
Yes
Yes
DS 5.0
Postprocessing: DS Detection cluster method: NMS / GroupRectangle / DBSCan / None
Yes
Yes
DS 5.0
Postprocessing: custom parsing (NvDsInferParseCustomTfSSD)
Yes
Yes
DS 5.0
Postprocessing: Triton native classification
Yes
Yes
DS 5.0
Triton Ensemble Mode (Triton preproc/postproc) with specified media-format (RGB/BGR/Gray) with Cuda GPU buffer as inputs
Yes
Yes
DS 5.0
Postprocessing: Attach Triton raw tensor output in NvDsInferTensorMeta for downstream or application postprocessing
Yes
Yes
DS 5.0
deepstream-app: pipeline works with PGIE / SGIE / nvtracker
Yes
Yes
DS 5.0
Sample App: deepstream-segmentation-test / deepstream-infer-tensor-meta-test
Yes
Yes
DS 5.0
Basic LSTM features on single batch and single stream (beta version, config file might be changed in future version)
Yes
Yes
DS 5.0

Gst-nvinferserver File Configuration Specifications

The Gst-nvinferserver configuration file uses prototxt format described in:
https://developers.google.com/protocol-buffers
The protobuf message structures of this configuration file are defined by nvdsinferserver_plugin.proto and nvdsinferserver_config.proto. All the basic data-type values are set to 0 or false from protobuf’s guide. Map, arrays and oneof are set to empty by default. See more details for each message definition.
The message PluginControl in nvdsinferserver_plugin.proto is the entry point for this config-file.
The message InferenceConfig configures the low-level settings for libnvds_infer_server.
The message PluginControl::InputControl configures the input buffers, objects filtering policy for model inference.
The message PluginControl::OutputControl configures inference output policy for detections and raw tensor metadata.
The message BackendParams configures backend input/output layers and Triton settings in InferenceConfig.
The message PreProcessParams configures network preprocessing information in InferenceConfig
The message PostProcessParams configures the output tensor parsing methods such as detection, classification, segmentation and others in InferenceConfig.
There are also other messages (e.g. CustomLib, ExtraControl) and enum types (e.g. MediaFormat, TensorOrder, ...) defined in the proto file for miscellaneous settings for InferenceConfig and PluginControl.
Gst-nvinferserver plugin, message PluginControl definition details
Fields
Meaning
Type and Range
Example
Notes
Network Types/ Applicable to GIEs (Primary/Secondary)
infer_config
Low-level libnvds_infer_server inference configuration settings
InferenceConfig
infer_config { … }
see details in InferenceConfig
All
Both
input_control
Control plugin input buffers, objects filtering policy for inference
PluginControl ::InputControl
input_control{
process_mode: PROCESS_MODE_FULL_FRAME
}
see details in InputControl
All
Both
output_control
Control plugin output metadata filtering policy after inference
PluginControl ::OutputControl
output_control { … }
see details in OutputControl
All
Both
 
Gst-nvinferserver plugin, message PluginControl::InputControl definition details
Property
Meaning
Type and Range
Example
Notes
Network Types/ Applicable to GIEs (Primary/Secondary)
process_mode
Processing mode, selected from PluginControl::ProcessMode. In deepstream-app PGIE uses PROCESS_MODE_FULL_FRAME by default, SGIE use PROCESS_MODE_CLIP_OBJECTS by default
enum PluginControl::ProcessMode
process_mode: PROCESS_MODE_FULL_FRAME
All
Both
operate_on_gie_id
Unique ID of the GIE on whose metadata (bounding boxes) this GIE is to operate on
int32, >=0, valid gie-id.
-1, disable gie-id check, inference on all GIE Ids
operate_on_gie_id: 1
All
Secondary
operate_on_class_ids
Class IDs of the parent GIE on which this GIE is to operate on
Comma delimited int32 array
operate_on_class_ids: [1, 2]
Operates on objects with class IDs 1, 2 generated by parent GIE
All
Secondary
interval
Specifies the number of consecutive, batches to be skipped for inference. default is 0
uint32
interval: 1
All
Primary
async_mode
Enables inference on detected objects and asynchronous metadata attachments. Works only when tracker-ids are attached. Pushes buffer downstream without waiting for inference results. Attaches metadata after the inference
bool
async_mode: false
Classifier
Secondary
object_control
input object filter settings
PluginControl::InputObjectControl
object_control {
bbox_filter {
min_width: 64
min_height: 64
}
}
see details in
InputObjectControl
All
Secondary
 
Gst-nvinferserver plugin, message PluginControl::OutputControl definition details
Property
Meaning
Type and Range
Example
Notes
Network Types/ Applicable to GIEs (Primary/Secondary)
output_tensor_meta
Enable attaching Inference output tensor metadata, tensor buffer pointer for host only
bool
output_tensor_meta: false
All
Both
detect_control
Specifies detection output filter policy
PluginControl::OutputDetectionControl
detect_control {
default_filter {
bbox_filter {
min_width: 32
min_height: 32
}
}
}
see details in OutputDetectionControl
Detector
Both
 
Gst-nvinferserver plugin, message PluginControl::InputObjectControl definition details
Fields
Meaning
Type and Range
Example
Notes
Network Types/ Applicable to GIEs (Primary/Secondary)
bbox_filter
Bounding box filter
PluginControl::BBoxFilter
 
bbox_filter {
min_width: 32
min_height: 32
}
see details in BBoxFilter
All
Secondary
 
Gst-nvinferserver plugin, message PluginControl::BBoxFilter definition details for Input and Output controls
Fields
Meaning
Type and Range
Example
Notes
Network Types / Applicable to GIEs (Primary/Secondary)
min_width
Bounding box minimum width 
uint32
min_width: 64
All
Both
min_height
Bounding box minimum height
uint32
min_height: 64
All
Both
max_width
Bounding box maximum width, default 0, max_width is ignored 
uint32
max_width: 640
All
Both
max_height
Bounding box maximum height.
default 0, max_height is ignored 
uint32
max_height: 640
All
Both
 
Gst-nvinferserver plugin, message PluginControl::OutputDetectionControl definition details
Fields
Meaning
Type and Range
Example
Notes
Network Types / Applicable to GIEs (Primary/Secondary)
default_filter
default detection filter for output controls
PluginControl::DetectClassFilter
default_filter {
bbox_filter {
min_width: 32
min_height: 32
}
}
see details in DetectClassFilter
All
Both
specific_class_filters
specifies detection filters per class to replace default filter
map<uint32, DetectClassFilter>
specific_class_filters: [
{ key: 1, value {...} },
{ key: 2,
value {...} }
]
All
Both
 
Gst-nvinferserver plugin, message PluginControl::DetectClassFilter definition details
Fields
Meaning
Type and Range
Example
Notes
Network Types/ Applicable to GIEs (Primary/Secondary)
bbox_filter
detection bounding box filter
PluginControl::BBoxFilter
bbox_filter {
min_width: 64
min_height: 64
}
Detection
Both
roi_top_offset
Offset of the RoI from the top of the frame. Only objects within the RoI are output.
 
uint32
roi_top_offset: 128
Detection
Both
roi_bottom_offset
Offset of the RoI from the bottom of the frame. Only objects within the RoI are output.
uint32
roi_bottom_offset: 
Detection
Both
border_color
specify border color for detection bounding boxes
PluginControl::Color
border_color {
r: 1.0
g: 0.0
b: 0.0
a: 1.0
}
Detection
Both
bg_color
specify background color for detection bounding boxes
PluginControl::Color
border_color { 
r: 0.0
g: 1.0
b: 0.0
a: 0.5
}
Detection
Both
 
Gst-nvinferserver plugin, message PluginControl::Color definition details
Fields
Meaning
Type and Range
Example
Notes
Network Types/ Applicable to GIEs (Primary/Secondary)
r
Red color value
float. Range[0.0, 1.0]
r: 0.5
All
Both
g
Green color value
float. Range[0.0, 1.0]
g: 0.5
All
Both
b
Blue color value
float. Range[0.0, 1.0]
b: 0.3
All
Both
a
Alpha blending value
float. Range[0.0, 1.0]
a: 1.0
All
Both
The message InferenceConfig defines all the low-level structure fields in nvdsinferserver_config.proto. It has major settings for inference backend, network preprocessing and postprocessing.
message InferenceConfig definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
unique_id
Unique ID identifying metadata generated by this GIE
uint32, ≥0
unique_id: 1
All
Both
gpu_ids
Device IDs of GPU to use for pre-processing/inference (single GPU support only)
int32 array, ≥0
gpu_ids: [0]
All
Both
max_batch_size
Max number of frames/objects to be inferred together in a batch
uint32, ≥0
max_batch_size: 1
All
Both
backend
Inference backend settings
BackendParams
backend {
trt_is { ... }
}
see details in BackendParams
All
Both
preprocess
Network preprocessing setting for color conversion scale and normalization
PreProcessParams
preprocess {
normalize { … }
}
see details in PreProcessParams
All
Both
postprocess
Inference output tensor parsing methods such as detection, classification, segmentation and others
PostProcessParams
postprocess {
detection {...}
}
see details in PostProcessParams
All
Both
custom_lib
Specify custom lib path for custom parsing functions and preloads, optional
CustomLib
custom_lib {
path : ./libcustom_parsing.so
}
All
Both
extra
extra controls for inference config.
ExtraControl
extra {
output_buffer_pool_size: 2
}
see details in ExtraControl
All
Both
lstm
LSTM control parameters, limited on batch-size 1 and single stream
LstmParams
[optional]
lstm {
loops {
input: “init_lstm_c”
output: “output/lstm_c”
init_const { value: 0 }
}
}
See details in LstmParams
All
Both
 
message BackendParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
inputs
Backend input layer settings, optional
InputLayer arrays
see details in InputLayer
All
Both
outputs
Backend output layer settings, optional
OutputLayer arrays
see details in OutputLayer
All
Both
trt_is
backend of Triton Inference Server settings
TrtISParams
see details in TrtISParams
All
Both
 
message InputLayer definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
name
input tensor name
string
name: “input_0”
All
Both
dims
input tensor shape, optional. only required if backend cannot figure out fixed input shapes
int32 array,
> 0
dims: [299, 299, 3]
All
Both
data_type
enum TensorDataType with types:
TENSOR_DT_NONE,
TENSOR_DT_FP32,
TENSOR_DT_FP16,
TENSOR_DT_INT8,
TENSOR_DT_INT16,
TENSOR_DT_INT32,
TENSOR_DT_UINT8,
TENSOR_DT_UINT16,
TENSOR_DT_UINT32
Default TENSOR_DT_NONE, usually can be deduced from Triton model config.pbtxt
TensorDataType
data_type: TENSOR_DT_FP32
All
Both
 
message OutputLayer definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
name
output tensor name
string
name: “detection_boxes”
All
Both
 
message TrtISParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
model_name
Triton inference model name
string
model_name: “ssd_inception_graphdef”
All
Both
version
Triton model version number.
-1, latest version number.
>0, reserved for specific version number in future version
int64
version: -1
All
Both
model_repo
Triton model repository settings.
Note, all model_repo settings must be same in single process
TrtISParams::ModelRepo
model_repo {
root: “../trtis_model_repo”
log_level: 2
}
see more details in ModelRepo
All
Both
 
message TrtISParams::ModelRepo definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
root
Triton inference model repository directory path 
string
root: “../trtis_model_repo”
All
Both
log_level
Triton log output levels
 
uint32;
0, ERROR;
1, WARNING;
2, INFO;
>=3, VERBOSE Level
log_level: 1
All
Both
strict_model_config
Enable Triton strict model configuration, see details in Triton Generated Model Configuration. Suggest setting value true
bool
strict_model_config: true
All
Both
tf_gpu_memory_fraction
TensorFlow GPU memory fraction per process. Valid for Tensorflow models only.
Default 0 means no GPU memory limitation. Suggest tuning to a proper value (e.g. in range of [0.2, 0.6]) in case Tensorflow uses up whole GPU memory
float,
Range (0, 1.0]
tf_gpu_memory_fraction: 0.6
All
Both
tf_disable_soft_placement
Disable TensorFlow soft placement of operators. It’s enabled by default.
bool
tf_disable_soft_placement: false
All
Both
 
message PreProcessParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
network_format
enum MediaFormat with formats:
MEDIA_FORMAT_NONE
IMAGE_FORMAT_RGB
IMAGE_FORMAT_BGR
IMAGE_FORMAT_GRAY
. use IMAGE_FORMAT_RGB by default.
MediaFormat
network_format: IMAGE_FORMAT_RGB
All
Both
tensor_order
enum TensorOrder with order types:
TENSOR_ORDER_NONE,
TENSOR_ORDER_LINEAR,
TENSOR_ORDER_NHWC.
It can deduce the value from backend layers info if set to TENSOR_ORDER_NONE
TensorOrder
tensor_order: TENSOR_ORDER_NONE
All
Both
tensor_name
Specify the tensor name for the preprocessing buffer.
This is in the case when multiple input tensors in a single network.
string;
Optional
tensor_name: “input_0”
All
Both
frame_scaling_hw
Compute hardware to use for scaling frames / object crops to network resolution
enum FrameScalingHW
FRAME_SCALING_HW_DEFAULT: Platform default – GPU (dGPU), VIC (Jetson)
FRAME_SCALING_HW_GPU
FRAME_SCALING_HW_VIC (Jetson only)
frame_scaling_hw: FRAME_SCALING_HW_GPU
All
Both
frame_scaling_filter
The filter to use for scaling frames / object crops to network resolution
int32, refer to enum NvBufSurfTransform_Inter in nvbufsurftransform.h for valid values
frame_scaling_filter: 1
All
Both
maintain_aspect_ratio
Indicates whether to maintain aspect ratio while scaling input.
int32;
0 or 1
maintain_aspect_ratio: 0
All
Both
normalize
Network input tensor normalization settings for scale-factors, offsets and mean-subtraction
PreProcessParams::ScaleNormalize
normalize {
scale_factor: 1.0
channel_offsets: [0, 0, 0]
}
see details in PreProcessParams::ScaleNormalize
 
 
message PreProcessParams::ScaleNormalize definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
scale_factor
Pixel normalization factor
float
scale_factor: 0.0078
All
Both
channel_offsets
Array of mean values of color components to be subtracted from each pixel. Array length must equal the number of color components in the frame. The plugin multiplies mean values by scale_factor
float array,
Optional
channel_offsets: [77.5, 21.2, 11.8]
All
Both
mean_file
Pathname of mean data file (PPM format)
string;
Optional
mean_file: “./model_meanfile.ppm”
All
Both
 
message PostProcessParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
labelfile_path
Pathname of a text file containing the labels for the model
string
labelfile_path: “=/home/ubuntu/model_labels.txt”
All
Both
oneof process_type
Indicates one of the postprocessing type
detection;
classification;
segmentation;
other;
None
N/A
All
Both
detection
Specify detection parameters for the network.
It must be oneof process_type
DetectionParams
detection {
num_detected_classes: 4
simple_cluster {
threshold: 0.2
}
}
see details in DetectionParams
Detector
Both
classification
Specify classification parameters for the network
It is oneof process_type
ClassificationParams
classification {
threshold: 0.6
}
see details in ClassificationParams
Classifier
Both
segmentation
Specify segmentation parameters for the network
It is oneof process_type
SegmentationParams
segmentation {
threshold: 0.2
}
Segmentation
Both
other
Specify other network parameters.
This is for user-defined networks and usually coexists with output_control.output_tensor_meta: true. Tensor output data would be attached into GstBuffer. Data can be parsed in application. User can increase extra.output_buffer_pool_size if need to hold metadata longer.
It is oneof process_type
OtherNetworkParams
other {}
see details in OtherNetworkParams
Others
Both
trtis_classification
Specify Triton classification parameters for the network
It is oneof process_type
TrtIsClassifyParams
trtis_classification {
topk: 1
}
see details in TrtIsClassifyParams
Classifier
Both
 
message DetectionParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
num_detected_classes
Define number of classes detected by the network
int32,
> 0
num_detected_classes:4
Detector
Both
per_class_params
Map of specific detection parameters per class. Key-value follows <class_id: per_class_params> order. 
map<int32, PerClassParams>;
Optional
per_class_params {
{ key: 1,
value { pre_threshold : 0.4}
},
{ key: 2,
value { pre_threshold : 0.5}
}
}
see details for PerClassParams
Detector
Both
custom_parse_bbox_func
Name of the custom bounding box parsing function. If not specified, Gst-nvinferserver uses the internal function for the resnet model provided by the SDK.
If specified, also need to set custom_lib to load custom library.
string;
custom_parse_bbox_func: "NvDsInferParseCustomTfSSD"
Detector
Both
oneof clustering_policy
Indicates one of the clustering policies from
nms;
dbscan;
group_rectangle;
simple_cluster;
None
N/A
Detector
Both
nms
Indicates clustering bounding boxes by Non-Maximum-Suppression method detected objects.
It is oneof clustering_policy
Nms
nms {
confidence_threshold: 0.3
iou_threshold: 0.4
}
see details in Nms
Detector
Both
dbscan
Indicates clustering bounding boxes by DBSCAN method for detected objects.
It is oneof clustering_policy
DbScan
dbscan {
pre_threshold: 0.3
eps: 0.7
min_boxes: 3
}
see details in DbScan
Detector
Both
group_rectangle
Indicates clustering bounding boxes by groupRectangles() function for grouping detected objects
It is oneof clustering_policy
GroupRectangle
group_rectangle {
confidence_threshold: 0.2
group_threshold: 2
eps: 0.2
}
Detector
Both
simple_cluster
Indicates simple clustering method by outlier boxes through threshold
SimpleCluster
simple_cluster {
threshold: 0.2
}
Detector
Both
 
message DetectionParams::PerClassParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
pre_threshold
Define confidence threshold per class
float
pre_threshold:0.3
Detector
Both
 
message DetectionParams::Nms definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
confidence_threshold
Detection score lesser than this threshold would be rejected
float
confidence_threshold:0.5
Detector
Both
iou_threshold
Maximum IOU score between two proposals after which the proposal with the lower confidence will be rejected.
float
iou_threshold: 0.3
Detector
Both
topk
Specify top k detection results to keep after nms
int32, >= 0
topk: 2;
value 0, means keep all.
Detector
Both
 
message DetectionParams::DbScan definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
pre_threshold
Detection score lesser than this threshold would be rejected before DBSCAN clustering
float
pre_threshold:0.2
Detector
Both
eps
DBSCAN epsilon to control merging of overlapping boxes.
float
eps: 0.7
Detector
Both
min_boxes
Minimum boxes in DBSCAN cluster to be considered an object
int32, > 0
min_boxes: 3;
Detector
Both
min_score
Minimum score in DBSCAN cluster for it to be considered as an object
float
min_score: 0.7
Default value is 0
Detector
Both
 
message DetectionParams::GroupRectangle definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
confidence_threshold
Detection score lesser than this threshold would be rejected
float
confidence_threshold:0.2
Detector
Both
group_threshold
Threshold value for rectangle merging for OpenCV grouprectangles() function
int32; >= 0
group_threshold: 1
Detector
Both
eps
Epsilon to control merging of overlapping boxes
float
eps: 0.2
Detector
Both
 
message DetectionParams::SimpleCluster definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
threshold
Detection score lesser than this threshold would be rejected
float
confidence_threshold:0.6
Detector
Both
message ClassificationParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
threshold
Classification score lesser than this threshold would be rejected
float
threshold: 0.5
Classifier
Both
custom_parse_classifier_func
Name of the custom classifier output parsing function.
If not specified, Gst-nvinfer uses the internal parsing function with NCHW tensor order for softmax layers. User can reshape other output tensor order to NCHW in TRTIS config.pbtxt to run internal parsing.
If specified, also need to set custom_lib to load custom library.
string
parse-classifier-func-name: “parse_bbox_softmax”
Classifier
Both
 
message SegmentationParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
threshold
Segmentation score lesser than this threshold would be rejected
float
threshold: 0.5
Segmentation
Both
 
message OtherNetworkParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
type_name
Specify a user-defined network name
string;
Optional
type_name: “face”
Others
Both
 
message TrtIsClassifyParams definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier/ Applicable to GIEs (Primary/Secondary)
topk
Specify top k elements need to keep from Triton’s native classification
uint32; >=0
topk : 1
Value 0 or empty would keep the top 1 result.
Classifier
Both
threshold
Classification score lesser than this threshold would be rejected
float
threshold: 0.5
Classifier
Both
 
message CustomLib definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
path
Pathname that points to a custom library for preload
string
path: “/home/ubuntu/lib_custom_impl.so”
All
Both
 
message ExtraControl definition details
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
copy_input_to_host_buffers
Enable to copy input tensor data to host buffers.
If enabled, input tensor would be attached as NvDsInferTensorMeta into GstBuffer with output tensors together
bool
copy_input_to_host_buffers: false
All
Both
output_buffer_pool_size
Specify the buffer pool size for each output tensor.
When infer_config.postprocess.other is specified or output_control.output_tensor_meta is enabled, the output tensor would be attached as NvDsInferTensorMeta into GstBuffer
int32;
Range [2, 10]
output_buffer_pool_size: 4
All
Both
 
message LstmParams definition details
Note: LstmParams structures might be changed in future versions
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
loops
Specify LSTM loops between input and output tensors.
LstmLoop
[repeated]
loops [ {
input: “init_state”
output: “out_state”
} ]
See details in LstmParams::LstmLoop
All
Both
 
message LstmParams::LstmLoop definition details
Note: input and output tensors must have same datatype/dimensions, FP16 is not supported
LstmParams::LstmLoop structures might be changed in future versions
Name
Description
Type and Range
Example
Notes
Detector or Classifier / Applicable to GIEs (Primary/Secondary)
input
Specify input tensor name of the current loop.
string
Input: “init_state”
All
Both
output
Specify input tensor name of the current loop. Tensor data will feedback to the input tensor
string
onput: “output_state”
All
Both
init_const
Specify the constant values for the input in first frame
InitConst
value: float
Init_const { value: 0 }
All
Both

Gst Properties

The values set through Gst properties override the values of properties in the configuration file. The application does this for certain properties that it needs to set programmatically. If user set property though plugin, these values would replace the original value in config files.
The following table describes the Gst-nvinferserver plugin’s Gst properties.
Gst-nvinferserver plugin, Gst properties
Property
Meaning
Type and Range
Example
Notes
config-file-path
Absolute pathname of configuration file for the Gst-nvinferserver element
String
config-file-path=config_infer_primary.txt
process-mode
Infer Processing Mode
(0):None, (1)FullFrame, (2)ClipObject.
If set, it could replace input_control.process_mode
 
Integer, 0, 1 or 2
process-mode=1
unique-id
Unique ID identifying metadata generated by this GIE.
If set, it could replace infer_config.unique_id
Integer,
0 to 4,294,967,295
unique-id=1
infer-on-gie-id
See input_control.operate_on_gie_id in the configuration file table
Integer,
0 to 4,294,967,295
infer-on-gie-id=1
operate-on-class-ids
See input_control.operate_on_class_ids in the configuration file table
An array of colon- separated integers (class-ids)
operate-on-class-ids=1:2:4
batch-size
Number of frames/objects to be inferred together in a batch.
If set, it could replace infer_config.max_batch_size
Integer,
1 – 4,294,967,295
batch-size=4
Interval
Number of consecutive batches to be skipped for inference
If set, it could replace input_control.interval
Integer, 0 to 32
interval=0
raw-output-generated-callback
Pointer to the raw output generated callback function
Pointer
Cannot be set through gst-launch
raw-output-generated-userdata
Pointer to user data to be supplied with raw-output-generated-callback
Pointer
Cannot be set through gst-launch

Triton Ensemble Models

The Gst-nvinferserver plugin can support Triton ensemble models for further custom preprocessing, backend and postprocessing through Triton custom-backends.
Triton ensemble model represents a pipeline of one or more models and the connection of input and output tensors between those models, such as “data preprocessing -> inference -> data postprocessing”. See more details
To manage memory efficiency and keep clean interface, The Gst-nvinferserver Plugin’s default preprocessing cannot be disabled. Color conversion, datatype conversion, input scaling and object cropping are continue working in nvds_infer_server natively. For example, in the case native normalization is not needed, update scale_factor to 1.0
infer_config { preprocess {
network_format: IMAGE_FORMAT_RGB
tensor_order: TENSOR_ORDER_LINEAR
normalize { scale_factor: 1.0 } } }
The low level nvds_infer_server library could deliver specified media-format (RGB/BGR/Gray) in any kind of tensor orders and datatypes as a Cuda GPU buffer input to Triton backend. User’s custom-backend must support GPU memory on this input. Triton custom-backend sample identity can work with Gst-nvinferserver plugin.
Note:
Custom backend API must have same Triton codebase version (v1.12.0)
For Jetson, download v1.12.0-jetpack4.4dp.tgz
To learn details how to implement Triton custom-backend, please refer to
For Triton model’s output, TRTSERVER_MEMORY_GPU and TRTSERVER_MEMORY_CPU buffer allocation are supported in nvds_infer_server according to Triton output request. This also works for ensemble model’s final output tensors.
Finally, inference data can be parsed by default detection, classification, or segmentation. Alternatively, user can implement custom-backend for postprocessing, then deliver the final output to Gst-nvinferserver plugin to do further processing. Besides that, User can also optionally attach raw tensor output data into metadata for downstream or application to parse.

Tensor Metadata

The Gst-nvinferserver plugin can attach raw output tensor data generated by the inference backend as metadata. It is added as an NvDsInferTensorMeta in the frame_user_meta_list member of NvDsFrameMeta for primary (full frame) mode, or in the obj_user_meta_list member of NvDsObjectMeta for secondary (object) mode. It uses same metadata structure with Gst-nvinferserver plugin.
Note:
Gst-nvinferserver plugin does not attach device buffer pointer NvDsInferTensorMeta::attach out_buf_ptrs_dev at this moment.
To read or parse inference raw tensor data of output layers
1. Enable
output_control { output_tensor_meta : true }
If native postprocessing need be disabled, update:
infer_config { postprocess { other {} } }
fields in the configuration file for the Gst-nvinferserver plugin.
2. When operating as primary GIE, NvDsInferTensorMeta is attached to each frame’s (each NvDsFrameMeta object’s) frame_user_meta_list. When operating as secondary GIE, NvDsInferTensorMeta is attached to each NvDsObjectMeta object’s obj_user_meta_list.
Metadata attached by Gst-nvinferserver can be accessed in a GStreamer pad probe attached downstream from the Gst-nvinferserver instance.
3. The NvDsInferTensorMeta object’s metadata type is set to NVDSINFER_TENSOR_OUTPUT_META. To get this metadata you must iterate over the NvDsUserMeta user metadata objects in the list referenced by frame_user_meta_list or obj_user_meta_list.
For more information about Gst-infer tensor metadata usage, see the source code in sources/apps/sample_apps/deepstream_infer_tensor_meta-test.cpp, provided in the DeepStream SDK samples.

Segmentation Metadata

The Gst-nvinferserver plugin attaches the output of the segmentation model as user meta in an instance of NvDsInferSegmentationMeta with meta_type set to NVDSINFER_SEGMENTATION_META. The user meta is added to the frame_user_meta_list member of NvDsFrameMeta for primary (full frame) mode, or the obj_user_meta_list member of NvDsObjectMeta for secondary (object) mode.
For guidance on how to access user metadata, see User/Custom Metadata Addition Inside NvDsMatchMeta and Tensor Metadata, above.

Gst-nvtracker

This plugin tracks detected objects and gives each new object a unique ID.
The plugin adapts a low-level tracker library to the pipeline. It supports any low-level library that implements the low-level API, including the three reference implementations, the NvDCF, KLT, and IOU trackers.
As part of this API, the plugin queries the low-level library for capabilities and requirements concerning input format and memory type. It then converts input buffers into the format requested by the low-level library. For example, the KLT tracker uses Luma-only format; NvDCF uses NV12 or RGBA; and IOU requires no buffer at all.
The low-level capabilities also include support for batch processing across multiple input streams. Batch processing is typically more efficient than processing each stream independently. If a low-level library supports batch processing, that is the preferred mode of operation. However, this preference can be overridden with the enable-batch-process configuration option if the low-level library supports both batch and per-stream modes.
The low-level capabilities also include support for passing the past-frame data, which includes the object tracking data generated in the past frames but not reported as output yet. This can be the case when the low-level tracker stores the object tracking data generated in the past frames internally because of, say, low confidence, but later decided to report due to, say, increased confidence. These past-frame data are reported as a user-meta. This can be enabled by the enable-past-frame configuration option.
The plugin accepts NV12/RGBA data from the upstream component and scales (converts) the input buffer to a buffer in the format required by the low-level library, with tracker width and height. (Tracker width and height must be specified in the configuration file’s [tracker] section.)
The low -level tracker library is selected via the ll-lib-file configuration option in the tracker configuration section. The selected low-level library may also require its own configuration file, which can be specified via the ll-config-file option.
The three reference low level libraries support different algorithms:
The KLT tracker uses a CPU-based implementation of the Kanade Lucas Tomasi (KLT) tracker algorithm. This library requires no configuration file.
The Intersection of Union (IOU) tracker uses the intersection of the detector’s bounding boxes across frames to determine the object’s unique ID. This library takes an optional configuration file.
The Nv-adapted Discriminative Correlation Filter (NvDCF) tracker uses a correlation filter-based online discriminative learning algorithm, coupled with a Hungarian algorithm for data association in multi-object tracking. This library accepts an optional configuration file.
`A screenshot of a cell phone Description automatically generated

Inputs and Outputs

This section summarizes the inputs, outputs, and communication facilities of the Gst-nvtracker plugin.
Inputs
Gst Buffer (batched)
NvDsBatchMeta
Formats supported are NV12 and RGBA.
Control parameters
tracker-width
tracker-height
gpu-id (for dGPU only)
ll-lib-file
ll-config-file
enable-batch-process
enable-past-frame
tracking-surface-type
display-tracking-id
Output
Gst Buffer (provided as an input)
NvDsBatchMeta (with addition of tracked object coordinates, tracker confidence and object IDs in NvDsObjectMeta)
Note:
If the tracker algorithm does not generate confidence value, then tracker confidence value will be set to -0.1 for tracked objects.
For KLT and IOU tracker tracker_confidence is set to -0.1 as these algorithms do not generate confidence values for tracked objects. Nvdcf tracker generates confidence for the tracked objects and its value is set in tracker_confidence field in NvDsObjectMeta structure

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvtracker plugin
Feature
Description
Release
Configurable tracker width/height
Frames are internally scaled to specified resolution for tracking
DS 2.0
Multi-stream CPU/GPU tracker
Supports tracking on batched buffers consisting of frames from different sources
DS 2.0
NV12 Input
DS 2.0
RGBA Input
DS 3.0
Allows low FPS tracking
IOU tracker
DS 3.0
Configurable GPU device
User can select GPU for internal scaling/color format conversions and tracking
DS2.0
Dynamic addition/deletion of sources at runtime
Supports tracking on new sources added at runtime and cleanup of resources when sources are removed
DS 3.0
Support for user’s choice of low-level library
Dynamically loads user selected low-level library
DS 4.0
Support for batch processing
Supports sending frames from multiple input streams to the low-level library as a batch if the low-level library advertises capability to handle that
DS 4.0
Support for multiple buffer formats as input to low-level library
Converts input buffer to formats requested by the low-level library, for up to 4 formats per frame
DS 4.0
Support for reporting past-frame data
Supports reporting past-frame data if the low-level library supports the capability
DS 5.0
Support for enabling tracking-id display
Supports enabling or disabling display of tracking-id
DS 5.0

Gst Properties

The following table describes the Gst properties of the Gst-nvtracker plugin.
Gst-nvtracker plugin, Gst Properties
Property
Meaning
Type and Range
Example
Notes
tracker-width
Frame width at which the tracker is to operate, in pixels.
Integer,
0 to 4,294,967,295
tracker-width=640
tracker-height
Frame height at which the tracker is to operate, in pixels.
Integer,
0 to 4,294,967,295
tracker-height=368
ll-lib-file
Pathname of the low-level tracker library to be loaded by Gst-nvtracker.
String
ll-lib-file=/opt/nvidia/deepstream/libnvds_nvdcf.so
ll-config-file
Configuration file for the low-level library if needed.
Path to configuration file
ll-config-file=/opt/nvidia/deepstream/tracker_config.yml
gpu-id
ID of the GPU on which device/unified memory is to be allocated, and with which buffer copy/scaling is to be done. (dGPU only.)
Integer,
0 to 4,294,967,295
gpu-id=1
enable-batch-process
Enables/disables batch processing mode. Only effective if the low-level library supports both batch and per-stream processing. (Optional.)
Boolean
enable-batch-process=1
enable-past-frame
Enables/disables reporting past-frame data mode. Only effective if the low-level library supports it.
Boolean
enable-past-frame=1
tracking-surface-type
Set surface stream type for tracking. (default value is 0)
Integer, ≥0
tracking-surface-type=0
display-tracking-id
Enables tracking id display on OSD.
Boolean
display-tracking-id=1
iou-threshold
Intersection over union threshold for considering two bounding boxes for association
float, [0..1]
tracker-width=0.6

Custom Low-Level Library

To write a custom low-level tracker library, implement the API defined in sources/includes/nvdstracker.h. Parts of the API refer to sources/includes/nvbufsurface.h.
The names of API functions and data structures are prefixed with NvMOT, which stands for NVIDIA Multi-Object Tracker.
This is the general flow of the API from a low-level library perspective:
1. The first required function is:
NvMOTStatus NvMOT_Query(
uint16_t customConfigFilePathSize,
char* pCustomConfigFilePath,
NvMOTQuery *pQuery
);
The plugin uses this function to query the low-level library’s capabilities and requirements before it starts any processing sessions (contexts) with the library. Queried properties include the input frame memory format (e.g., RGBA or NV12), memory type (e.g., NVIDIA® CUDA® device or CPU mapped NVMM), and support for batch processing.
The plugin performs this query once, and its results apply to all contexts established with the low-level library. If a low-level library configuration file is specified, it is provided in the query for the library to consult.
The query reply structure NvMOTQuery contains the following fields:
NvMOTCompute computeConfig: Reports compute targets supported by the library. The plugin currently only echoes the reported value when initiating a context.
uint8_t numTransforms: The number of color formats required by the low-level library. The valid range for this field is 0 to NVMOT_MAX_TRANSFORMS. Set this to 0 if the library does not require any visual data. Note that 0 does not mean that untransformed data will be passed to the library.
NvBufSurfaceColorFormat colorFormats[NVMOT_MAX_TRANSFORMS]: The list of color formats required by the low-level library. Only the first numTransforms entries are valid.
NvBufSurfaceMemType memType: Memory type for the transform buffers. The plugin allocates buffers of this type to store color and scale-converted frames, and the buffers are passed to the low-level library for each frame. Note that support is currently limited to the following types:
dGPU: NVBUF_MEM_CUDA_PINNED
NVBUF_MEM_CUDA_UNIFIED
Jetson: NVBUF_MEM_SURFACE_ARRAY
bool supportBatchProcessing: True if the low-library support batch processing across multiple streams; otherwise false.
bool supportPastFrame: True if the low-library support outputting past frame; otherwise false.
2. After the query, and before any frames arrive, the plugin must initialize a context with the low-level library by calling:
NvMOTStatus NvMOT_Init(
NvMOTConfig *pConfigIn,
NvMOTContextHandle *pContextHandle,
NvMOTConfigResponse *pConfigResponse
);
The context handle is opaque outside the low-level library. In batch processing mode, the plugin requests a single context for all input streams. In per-stream processing mode, the plugin makes this call for each input stream so that each stream has its own context.
This call includes a configuration request for the context. The low-level library has an opportunity to:
Review the configuration and create a context only if the request is accepted. If any part of the configuration request is rejected, no context is created, and the return status must be set to NvMOTStatus_Error. The pConfigResponse field can optionally contain status for specific configuration items.
Pre-allocate resources based on the configuration.
Note:
In the NvMOTMiscConfig structure, the logMsg field is currently unsupported and uninitialized.
The customConfigFilePath pointer is only valid during the call.
3. Once a context is initialized, the plugin sends frame data along with detected object bounding boxes to the low-level library each time it receives such data from upstream. It always presents the data as a batch of frames, although the batch can contain only a single frame in per-stream processing contexts. Note that depending on the frame arrival timings to the tracker plugin, the composition of frame batches could either be full batch (that contains a frame from all streams) or partial batch (that contains a frame from only a subset of the streams). In either case, each batch is guaranteed to contain at most one frame from each stream.
The function call for this processing is:
NvMOTStatus NvMOT_Process(NvMOTContextHandle contextHandle,
NvMOTProcessParams *pParams,
NvMOTTrackedObjBatch *pTrackedObjectsBatch
);
Where:
pParams is a pointer to the input batch of frames to process. The structure contains a list of one or more frames, with at most one frame from each stream. No two frame entries have the same streamID. Each entry of frame data contains a list of one or more buffers in the color formats required by the low-level library, as well as a list of object descriptors for the frame. Most libraries require at most one-color format.
pTrackedObjectsBatch is a pointer to the output batch of object descriptors. It is pre-populated with a value for numFilled, the number of frames included in the input parameters.
If a frame has no output object descriptors, it is still counted in numFilled and is represented with an empty list entry (NvMOTTrackedObjList). An empty list entry has the correct streamID set and numFilled set to 0.
Note:
The output object descriptor NvMOTTrackedObj contains a pointer to the associated input object, associatedObjectIn. You must set this to the associated input object only for the frame where the input object is passed in. For example:
Frame 0: NvMOTObjToTrack X is passed in. The tracker assigns it ID 1, and the output object associatedObjectIn points to X.
Frame 1: Inference is skipped, so there is no input object. The tracker finds object 1, and the output object associatedObjectIn points to NULL.
Frame 2: NvMOTObjToTrack Y is passed in. The tracker identifies it as object 1. The output object 1 has associatedObjectIn pointing to Y.
4. Depending on the capability of the low-level tracker, there could be some tracked object data generated in the past frames but stored internally without being reported due to, say, low confidence in the past frames. If it becomes more confident in the later frames and ready to report them, then those past-frame data can be retrieved from the tracker plug-in using the following function call. Past frame data is outputted to batch_user_meta_list in NvDsBatchMeta:
NvMOTStatus NvMOT_ProcessPast(NvMOTContextHandle contextHandle,
NvMOTProcessParams *pParams,
NvDsPastFrameObjBatch *pPastFrameObjBatch
);
Where:
pParams is a pointer to the input batch of frames to process. This structure is needed to check the list of streamID in the batch.
pPastFrameObjBatch is a pointer to the output batch of object descriptors generated in the past frames. The data structure NvDsPastFrameObjBatch is defined in include/nvds_tracker_meta.h. It may include a set of tracking data for each stream in the input. For each object, there could be multiple past-frame data in case the tracking data is stored for multiple frames for the object.
5. In case that a video stream source is removed on the fly, the plugin calls the following function so that the low-level tracker lib can remove it as well. Note that this API is optional and valid only when the batch processing mode is enabled, meaning that it will be executed only when the low-level tracker lib has an actual implementation. If called, the low-level tracker lib can release any per-stream resource that it may be allocated:
void NvMOT_RemoveStreams(NvMOTContextHandle contextHandle, NvMOTStreamId streamIdMask);
6. When all processing is complete, the plugin calls this function to clean up the context:
void NvMOT_DeInit(NvMOTContextHandle contextHandle);

Low-Level Tracker Library Comparisons and Tradeoffs

DeepStream 5.0 provides three low-level tracker libraries which have different resource requirements and performance characteristics, in terms of accuracy, robustness, and efficiency, allowing you to choose the best tracker based on you use case. See the following table for comparison.
Tracker library comparison
Tracker
Computational Load
Pros
Cons
Best Use Cases
GPU
CPU
IOU
X
Very Low
Light weight
No visual features for matching, so prone to frequent tracker ID switches and failures.
Not suitable for fast moving scene.
Objects are sparsely located, with distinct sizes.
Detector is expected to run every frame or very frequently (ex. every alternate frame).
KLT
X
High
Works reasonably well for simple scenes
High CPU utilization.
Susceptible to change in the visual appearance due to noise and perturbations, such as shadow, non-rigid deformation, out-of-plane rotation, and partial occlusion.
Cannot work on objects with low textures.
Objects with strong textures and simpler background.
Ideal for high CPU resource availability.
NvDCF
Medium
Low
Highly robust against partial occlusions, shadow, and other transient visual changes.
 
Less frequent ID switches.
Slower than KLT and IOU due to increased computational complexity.
Reduces the total number of streams processed.
Multi-object, complex scenes with partial occlusion.

NvDCF Low-Level Tracker

NvDCF is a reference implementation of the custom low-level tracker library that supports multi-stream, multi-object tracking in a batch mode using a discriminative correlation filter (DCF) based approach for visual object tracking and a data association algorithm (such as Hungarian algorithm) based on visual and contextual data.
NvDCF allocates memory during initialization based on:
The number of streams to be processed
The maximum number of objects to be tracked per stream (denoted as maxTargetsPerStream in a configuration file for the NvDCF low-level library, tracker_config.yml)
Once the number of objects being tracked reaches the configured maximum value, any new objects will be discarded until resources for some existing tracked objects are released. Note that the number of objects being tracked includes objects that are tracked in Shadow Mode (described below). Therefore, NVIDIA recommends that you make maxTargetsPerStream large enough to accommodate the maximum number of objects of interest that may appear in a frame, as well as the objects that may have been tracked from past frames in shadow mode. To allow NvDCF to store and report such objects tracked in shadow-mode from past frames (i.e., past-frame data), user would need to set useBufferedOutput: 1 in low-level config (e.g., tracker_config.yml) and enable-past-frame=1, enable-batch-process=1 under [tracker] in the deepstream-app config file, since past frame is only supported in the batch processing mode in this release. Also, note that GPU memory usage by NvDCF is linearly proportional to the total number of objects being tracked, which is (number of video streams) × (maxTargetsPerStream).
DCF-based trackers typically apply an exponential moving average for temporal consistency when the optimal correlation filter is created and updated over consecutive frames. The learning rate for this moving average can be configured as filterLr. The standard deviation for Gaussian for desired response when creating an optimal DCF filter can also be configured as gaussianSigma.
DCF-based trackers also define a search region around the detected target location large enough for the same target to be detected in the search region in the next frame. The SearchRegionPaddingScale property determines the size of the search region as a multiple of the target’s bounding box size. For example, with SearchRegionPaddingScale:3, the size of the search region would be:
Where w and h are the width and height of the target’s bounding box.
Once the search region is defined for each target, the image patches for the search regions are cropped and scaled to a predefined feature image size, then the visual features are extracted. The featureImgSizeLevel property defines the size of the feature image. A lower value of featureImgSizeLevel causes NvDCF to use a smaller feature size, increasing GPU performance at the cost of accuracy and robustness.
Consider the relationship between featureImgSizeLevel and SearchRegionPaddingScale when configuring the parameters. If SearchRegionPaddingScale is increased while featureImgSizeLevel is fixed, the number of pixels corresponding to the target in the feature images is effectively decreased.
The minDetectorConfidence property sets confidence level below which object detection results are filtered out.
To achieve robust tracking, NvDCF employs two approaches to handling false alarms from PGIE detectors: late activation for handling false positives and shadow tracking for false negatives. Whenever a new object is detected a new tracker is instantiated in temporary mode. It must be activated to be considered as a valid target. Before it is activated it undergoes a probationary period, defined by probationAge, in temporary mode. If the object is not detected in more than earlyTerminationAge consecutive frames during the period, the tracker is terminated early.
Once the tracker for an object is activated, it is put into inactive mode only when (1) no matching detector input is found during the data association, or (2) the tracker confidence falls below a threshold defined by minTrackerConfidence. The per-object tracker will be put into active mode again if a matching detector input is found. The length of period during which a per-object tracker is in inactive mode is called the shadow tracking age; if it reaches the threshold defined by maxShadowTrackingAge, the tracker is terminated. Even if an object is being tracked in inactive mode, if the tracker confidence value is higher than minTrackingConfidenceDuringInactive, then the tracker will put the output into the metadata. Note if the value of minTrackingConfidenceDuringInactive is set too low, then some lingering bounding boxes may be observed occasionally after the objects disappear from the scene. If the bounding box of an object being tracked goes partially out of the image frame and so its visibility falls below a predefined threshold defined by minVisibiilty4Tracking, the tracker is also terminated.
NvDCF can generate a unique ID to some extent. If enabled by setting `useUniqueID: 1`, NvDCF would generate a 32-bit random number at the initialization stage and use it as the upper 32-bit of the following target ID generation, which is uint64_t type. The randomly generated upper 32-bit number allows the target ID to increment from a random position in the possible ID space. The initial value of the lower 32-bit of the target ID starts from 0. If disabled (which is the default value), the target ID generation would be incremented from 0.
NvDCF employs two types of state estimators: MovingAvgEstimator (MAE) and Kalman Filter (KF). Both KF and MAE have 7 states defined, which include {x, y, a, h, dx, dy, dh}, where x and y indicate the coordinates of the top-left corner of a target bbox, while a and h do the aspect ratio and the height of the bbox, respectively. dx, dy, and dh are the velocity of the three parameters. KF employs a constant velocity model for generic use. The measurement vector is defined as {x, y, a, h}. The process noise variance for {x, y}, {a, h}, and {dx, dy, dh} can be configured by `kfProcessNoiseVar4Loc`, `kfProcessNoiseVar4Scale`, and `kfProcessNoiseVar4Vel`, respectively. Note that from the state estimator’s point of view, there could be two different measurements: the bbox from the detector (i.e., PGIE) and the bbox from the tracker. This is because NvDCF is capable of localizing targets using its learned filter. The measurement noise variance for these two different types of measurements can be configured by `kfMeasurementNoiseVar4Det` and `kfMeasurementNoiseVar4Trk`. MAE is much simpler than KF, so more efficient in processing. The learning rate for the moving average of the defined states can be configured by `trackExponentialSmoothingLr_loc`, `trackExponentialSmoothingLr_scale`, and `trackExponentialSmoothingLr_velocity`.
To enhance the robustness, NvDCF allows to add the cross-correlation score to nearby objects as an additional regularization term, which is referred to as instance-awareness. If enabled by `useInstanceAwareness`, the number of nearby instances and the regularization weight for each instance would be determined by the config params `maxInstanceNum_ia` and `lambda_ia`, respectively.
The following table summarizes the configuration parameters for an NvDCF low-level tracker.
NvDCF low-level tracker, configuration properties
Property
Meaning
Type and Range
Example
Notes
useUniqueID
Enable unique ID generation scheme
Boolean
useUniqueID: 1
maxTargetsPerStream
Max number of targets to track per stream
Integer,
0 to 65535
maxTargetsPerStream: 30
useColorNames
Use ColorNames feature
Boolean
useColorNames: 1
useHog
Use Histogram-of-Oriented-Gradient (HOG) feature
Boolean
useHog: 1
useHighPrecisionFeature
Use high-precision numerical computation in feature extraction
Boolean
useHighPrecisionFeature: 1
filterLr
Learning rate for DCF filter in exponential moving average
Float,
0.0 to 1.0
filterLr: 0.11
filterChannelWeightsLr
Learning rate for weights for different feature channels in DCF
Float,
0.0 to 1.0
filterChannelWeightsLr: 0.22
gaussianSigma
Standard deviation for Gaussian for desired response
Float,
>0.0
gaussianSigma: 0.75
featureImgSizeLevel
Size of a feature image
Integer,
1 to 5
featureImgSizeLevel: 1
SearchRegionPaddingScale
Search region size
Integer,
1 to 3
SearchRegionPaddingScale: 3
minDetectorConfidence
Minimum detector confidence for a valid object
Float,
-inf to inf
minDetectorConfidence: 0.0
minTrackerConfidence
Minimum detector confidence for a valid target
Float,
0.0 to 1.0
minTrackerConfidence: 0.6
minTargetBboxSize
Minimum bbox size for a valid target [pixel]
Int, ≥0
minTargetBboxSize: 10
minDetectorBboxVisibilityTobeTracked
Minimum detector bbox visibility for a valid candidate
Float,
0.0 to 1.0
minDetectorBboxVisibilityTobeTracked: 0
minVisibiilty4Tracking
Minimum visibility of target bounding box to be considered valid
Float,
0.0 to 1.0
minVisibiilty4Tracking: 0.1
targetDuplicateRunInterval
Interval in which duplicate target removal is carried out [frame]
Int, -inf to inf
targetDuplicateRunInterval: 5
minIou4TargetDuplicate
Min IOU for two bboxes to be considered as duplicates
Float,
0.0 to 1.0
minIou4TargetDuplicate: 0.9
useGlobalMatching
Enable Hungarian method for data association
Boolean
useGlobalMatching: 1
maxShadowTrackingAge
Maximum length of shadow tracking
Integer, ≥0
maxShadowTrackingAge: 9
probationAge
Length of probationary period
Integer, ≥0
probationAge: 12
earlyTerminationAge
Early termination age
Integer, ≥0
earlyTerminationAge: 2
minMatchingScore4Overall
Min total score for valid matching
Float,
0.0 to 1.0
minMatchingScore4Overall: 0
minMatchingScore4SizeSimilarity
Min bbox size similarity score for valid matching
Float,
0.0 to 1.0
minMatchingScore4SizeSimilarity: 0.5
minMatchingScore4Iou
Min IOU score for valid matching
Float,
0.0 to 1.0
minMatchingScore4Iou: 0.1
minMatchingScore4VisualSimilarity
Min visual similarity score for valid matching
Float,
0.0 to 1.0
minMatchingScore4VisualSimilarity: 0.2
minTrackingConfidenceDuringInactive
Min tracking confidence during INACTIVE period
Float,
0.0 to 1.0
minTrackingConfidenceDuringInactive: 0.9
matchingScoreWeight4VisualSimilarity
Weight for visual similarity term in matching cost function
Float,
0.0 to 1.0
matchingScoreWeight4VisualSimilarity: 0.8
matchingScoreWeight4SizeSimilarity
Weight for size similarity term in matching cost function
Float,
0.0 to 1.0
matchingScoreWeight4SizeSimilarity: 0
matchingScoreWeight4Iou
Weight for IOU term in matching cost function
Float,
0.0 to 1.0
matchingScoreWeight4Iou: 0.1
matchingScoreWeight4Age
Weight for tracking age term in matching cost function
Float,
0.0 to 1.0
matchingScoreWeight4Age: 0.1
useTrackSmoothing
Enable state estimator
Boolean
useTrackSmoothing: 1
stateEstimatorType
Type of state estimator among {MovingAvg: 1, Kalman: 2}
Int
stateEstimatorType: 2
trackExponentialSmoothingLr_loc
Learning rate for location
Float,
0.0 to 1.0
trackExponentialSmoothingLr_loc: 0.5
trackExponentialSmoothingLr_scale
 
Learning rate for scale
Float,
0.0 to 1.0
trackExponentialSmoothingLr_scale: 0.3
trackExponentialSmoothingLr_velocity
Learning rate for velocity
Float,
0.0 to 1.0
trackExponentialSmoothingLr_velocity: 0.05
kfProcessNoiseVar4Loc
Process noise variance for location
Float, ≥0
kfProcessNoiseVar4Loc: 0.1
kfProcessNoiseVar4Scale
Process noise variance for scale
Float, ≥0
kfProcessNoiseVar4Scale: 0.04
kfProcessNoiseVar4Vel
Process noise variance for velocity
Float, ≥0
kfProcessNoiseVar4Vel: 0.04
kfMeasurementNoiseVar4Trk
Measurement noise variance for tracker bbox
Float, ≥0
kfMeasurementNoiseVar4Trk: 9
kfMeasurementNoiseVar4Det
Measurement noise variance for detector bbox
Float, ≥0
kfMeasurementNoiseVar4Det: 9
useBufferedOutput
Enable storing of past-frame data in a buffer and report it back
Boolean
useBufferedOutput: 1
useInstanceAwareness
Enable instance-awareness for multi-object tracking
Boolean
useInstanceAwareness: 1
lambda_ia
Regularlization factor for each instance
Float, ≥0
lambda_ia: 2
maxInstanceNum_ia
The number of nearby object instances to use for instance-awareness
Integer, ≥0
maxInstanceNum_ia: 4

IOU Low-Level Tracker

IOU Low-Level tracker uses intersection over union between detected bounding boxes across frames to track objects. Its optional configuration file contains a single entry as iou-threshold. This configuration is best left at default value of 0.6. In certain cases where objects are sparse with low bounding box overlap, it may help to lower the threshold.

KLT Low-Level Tracker

KLT Low-Level tracker performs feature extraction on image on which objects are to be tracked. It also performs optical flow tracking on the features between two frames using multi resolution pyramid. The objects are tracked based on feature points lying inside the bounding box. Feature extraction is performed whenever primary detection is performed.

Gst-nvstreammux

The Gst-nvstreammux plugin forms a batch of frames from multiple input sources. When connecting a source to nvstreammux (the muxer), a new pad must be requested from the muxer using gst_element_get_request_pad() and the pad template "sink_%u". For more information, see link_element_to_streammux_sink_pad() in the DeepStream app source code.
The muxer forms a batched buffer of batch-size frames. (batch-size is specified using the gst object property.)
If the muxer’s output format and input format are the same, the muxer forwards the frames from that source as a part of the muxer’s output batched buffer. The frames are returned to the source when muxer gets back its output buffer. If the resolution is not the same, the muxer scales frames from the input into the batched buffer and then returns the input buffers to the upstream component.
The muxer pushes the batch downstream when the batch is filled, or the batch formation timeout batched-pushed-timeout is reached. The timeout starts running when the first buffer for a new batch is collected.
The muxer uses a round-robin algorithm to collect frames from the sources. It tries to collect an average of (batch-size/num-source) frames per batch from each source (if all sources are live and their frame rates are all the same). The number varies for each source, though, depending on the sources’ frame rates.
The muxer outputs a single resolution (i.e. all frames in the batch have the same resolution). This resolution can be specified using the width and height properties. The muxer scales all input frames to this resolution. The enable-padding property can be set to true to preserve the input aspect ratio while scaling by padding with black bands.
For DGPU platforms, the GPU to use for scaling and memory allocations can be specified with the gpu-id property.
For each source that needs scaling to the muxer’s output resolution, the muxer creates a buffer pool and allocates four buffers each of size:
Where f is 1.5 for NV12 format, or 4.0 for RGBA. The memory type is determined by the nvbuf-memory-type property.
Set the live-source property to true to inform the muxer that the sources are live. In this case the muxer attaches the PTS of the last copied input buffer to the batched Gst Buffer’s PTS. If the property is set to false, the muxer calculates timestamps based on the frame rate of the source which first negotiates capabilities with the muxer.
The muxer attaches an NvDsBatchMeta metadata structure to the output batched buffer. This meta contains information about the frames copied into the batch (e.g. source ID of the frame, original resolutions of the input frames, original buffer PTS of the input frames). The source connected to the Sink_N pad will have pad_index N in NvDsBatchMeta.
The muxer supports addition and deletion of sources at run time. When the muxer receives a buffer from a new source, it sends a GST_NVEVENT_PAD_ADDED event. When a muxer sink pad is removed, the muxer sends a GST_NVEVENT_PAD_DELETED event. Both events contain the source ID of the source being added or removed (see sources/includes/gst-nvevent.h). Downstream elements can reconfigure when they receive these events. Additionally, the muxer also sends a GST_NVEVENT_STREAM_EOS to indicate EOS from the source.
The muxer supports calculation of NTP timestamps for source frames. It supports two modes. In the system timestamp mode, the muxer attaches the current system time as NTP timestamp. In the RTCP timestamp mode, the muxer uses RTCP Sender Report to calculate NTP timestamp of the frame when the frame was generated at source. The NTP timestamp is set in ntp_timestamp field of NvDsFrameMeta. The mode can be toggled by setting the "attach-sys-ts" property. For more details, refer to section NTP Timestamp in DeepStream.
A picture containing clock Description automatically generated

Inputs and Outputs

Inputs
NV12/RGBA buffers from an arbitrary number of sources
Control Parameters
batch-size
batched-push-timeout
width
height
enable-padding
gpu-id (dGPU only)
live-source
nvbuf-memory-type
num-surfaces-per-frame
buffer-pool-size
attach-sys-ts
Output
NV12/RGBA batched buffer
GstNvBatchMeta (meta containing information about individual frames in the batched buffer)

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvstreammux plugin
Feature
Description
Release
Configurable batch size
DS 2.0
Configurable batching timeout
DS 2.0
Allows multiple input streams with different resolutions
DS 2.0
Allows multiple input streams with different frame rates
DS 2.0
Scales to user-determined resolution in muxer
DS 2.0
Scales while maintaining aspect ratio with padding
DS 2.0
Multi-GPU support
DS 2.0
Input stream DRC support
DS 3.0
User-configurable CUDA memory type (Pinned/Device/Unified) for output buffers
DS 3.0
Custom message to inform application of EOS from individual sources
DS 3.0
Supports adding and deleting run time sinkpads (input sources) and sending custom events to notify downstream components
DS 3.0
Supports RGBA data handling at output
DS 3.0

Gst Properties

The following table describes the Gst-nvstreammux plugin’s Gst properties.
Gst-nvstreammux plugin, Gst properties
Property
Meaning
Type and Range
Example
Notes
batch-size
Maximum number of frames in a batch.
Integer,
0 to 4,294,967,295
batch-size=30
batched-push-timeout
Timeout in microseconds to wait after the first buffer is available to push the batch even if a complete batch is not formed.
Signed integer,
-1 to 2,147,483,647
batched-push-timeout= 40000
40 msec
width
If non-zero, muxer scales input frames to this width.
Integer,
0 to 4,294,967,295
width=1280
height
If non-zero, muxer scales input frames to this height.
Integer,
0 to 4,294,967,295
height=720
enable-padding
Maintains aspect ratio by padding with black borders when scaling input frames.
Boolean
enable-padding=1
gpu-id
ID of the GPU on which to allocate device or unified memory to be used for copying or scaling buffers. (dGPU only.)
Integer,
0 to 4,294,967,295
gpu-id=1
live-source
Indicates to muxer that sources are live, e.g. live feeds like an RTSP or USB camera.
Boolean
live-source=1
nvbuf-memory-type
Type of memory to be allocated.
For dGPU:
0 (nvbuf-mem-default): Default memory, cuda-device
1 (nvbuf-mem-cuda-pinned): Pinned/Host CUDA memory
2 (nvbuf-mem-cuda-device) Device CUDA memory
3 (nvbuf-mem-cuda-unified): Unified CUDA memory
For Jetson:
0 (nvbuf-mem-default): Default memory, surface array
4 (nvbuf-mem-surface-array): Surface array memory
Integer, 0-4
nvbuf-memory-type=1
num-surfaces-per-frame
Maximum number of surfaces per frame
Integer, 1-4
num-surfaces-per-frame=4
buffer-pool-size
Number of buffers in buffer pool
Integer<=1024
buffer-pool-size=4
attach-sys-ts
Attach system timestamp as ntp timestamp, otherwise ntp timestamp calculated from RTCP sender reports
boolean
attach-sys-ts=TRUE

Gst-nvstreamdemux

The Gst-nvstreamdemux plugin demuxes batched frames into individual buffers. It creates a separate Gst Buffer for each frame in the batch. It does not copy the video frames. Each Gst Buffer contains a pointer to the corresponding frame in the batch.
The plugin pushes the unbatched Gst Buffer objects downstream on the pad corresponding to each frame’s source. The plugin gets this information through the NvDsBatchMeta attached by Gst-nvstreammux. The original buffer timestamps (PTS) of individual frames are also attached back to the Gst Buffer.
Since there is no frame copy, the input Gst Buffer is not returned upstream immediately. When all of the non-batched Gst Buffer objects demuxed from an input batched Gst Buffer are returned to the demuxer by the downstream component, the input batched Gst Buffer is returned upstream.
The demuxer does not scale the buffer back to the source’s original resolution even if Gst-nvstreammux has scaled the buffers.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
Gst Buffer (batched)
NvDsBatchMeta
Other meta
Control parameters
None
Output
Gst Buffer (non-batched, single source)
Meta related to each Gst Buffer source
This plugin can be tested with the following pipelines:

Use case 1:

Two video sources are mux’ed together using nvstreammux.
The muxer’s output goes to nvinfer which is configured with batch-size=2.
After nvinfer, we use nvstreamdemux to display the contents of video source 0, and 1 along with inference output for each overlaid using nvdsosd plugin on two separate windows.
Pipeline (x86):
gst-launch-1.0 -e nvstreammux name=mux batch-size=2 width=1920 height=1080 ! nvinfer config-file-path=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/config_infer_primary.txt batch-size=2 ! nvstreamdemux name=demux filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_1080p_h264.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! queue ! mux.sink_0 filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_1 demux.src_0 ! "video/x-raw(memory:NVMM), format=NV12" ! queue ! nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! nvdsosd ! nvvideoconvert ! nveglglessink demux.src_1 ! queue ! "video/x-raw(memory:NVMM), format=NV12" ! queue ! nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! nvdsosd ! nveglglessink
Pipeline (Jetson):
gst-launch-1.0 -e nvstreammux name=mux batch-size=2 width=1920 height=1080 ! nvinfer config-file-path=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/config_infer_primary.txt batch-size=2 ! nvstreamdemux name=demux filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_1080p_h264.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! queue ! mux.sink_0 filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_1 demux.src_0 ! "video/x-raw(memory:NVMM), format=NV12" ! queue ! nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! nvdsosd ! nvvideoconvert ! nveglglessink demux.src_1 ! queue ! "video/x-raw(memory:NVMM), format=NV12" ! queue ! nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! nvegltransform ! nveglglessink

Use case 2:

Two video sources are mux’ed together using nvstreammux.
The muxer’s output goes to nvinfer which is configured with batch-size=2.
After nvinfer, we use nvstreamdemux to write the contents of video source 0 along with inference output overlaid using nvdsosd plugin to a file.
The contents of video source 1 post demux is directly displayed on screen using nveglglessink plugin
Pipeline (x86):
gst-launch-1.0 -e nvstreammux name=mux batch-size=2 width=1920 height=1080 ! nvinfer config-file-path=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/config_infer_primary.txt batch-size=2 ! nvstreamdemux name=demux filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_0 filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_1 demux.src_0 ! "video/x-raw(memory:NVMM), format=NV12" ! queue ! nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! nvdsosd ! nvvideoconvert ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=./out.mp4 demux.src_1 ! queue ! nveglglessink
Pipeline (Jetson):
gst-launch-1.0 -e nvstreammux name=mux batch-size=2 width=1920 height=1080 ! nvinfer config-file-path=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/config_infer_primary.txt batch-size=2 ! nvstreamdemux name=demux filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_0 filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_1 demux.src_0 ! "video/x-raw(memory:NVMM), format=NV12" ! queue ! nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! nvdsosd ! nvvideoconvert ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=./out.mp4 demux.src_1 ! queue ! nvegltransform ! nveglglessink

Use case 3:

Use case 3 demonstrates displaying both streams as it is in two separate windows.
Two video sources are mux’ed together using nvstreammux.
The muxer’s output goes to nvinfer which is configured with batch-size=2.
After nvinfer, we use nvstreamdemux to display the contents of video source 0, and 1 on two separate windows.
Pipeline (x86):
gst-launch-1.0 -e nvstreammux name=mux batch-size=2 width=1920 height=1080 ! nvinfer config-file-path=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/config_infer_primary.txt batch-size=2 ! nvstreamdemux name=demux filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_0 filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_1 demux.src_0 ! queue ! nvvideoconvert ! nveglglessink demux.src_1 ! queue ! nveglglessink
Pipeline (Jetson):
gst-launch-1.0 -e nvstreammux name=mux batch-size=2 width=1920 height=1080 ! nvinfer config-file-path=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/config_infer_primary.txt batch-size=2 ! nvstreamdemux name=demux filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_0 filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_1 demux.src_0 ! queue ! nvegltransform ! nveglglessink demux.src_1 ! queue ! nvegltransform ! nveglglessink

Gst-nvmultistreamtiler

The Gst-nvmultistreamtiler plugin composites a 2D tile from batched buffers. The plugin accepts batched NV12/RGBA data from upstream components. The plugin composites the tile based on stream IDs, obtained from NvDsBatchMeta and NvDsFrameMeta in row-major order (starting from source 0, left to right across the top row, then across the next row). Each source frame is scaled to the corresponding location in the tiled output buffer. The plugin can reconfigure if a new source is added and it exceeds the space allocated for tiles. It also maintains a cache of old frames to avoid display flicker if one source has a lower frame rate than other sources.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
Gst Buffer batched buffer
NvDsBatchMeta with Gst Buffer batched (batch is one or more buffers)
Formats supported: NV12/RGBA
Control Parameters
rows
columns
width
height
gpu-id (dGPU only)
show-source
nvbuf-memory-type
custom-tile-config
Output
Gst Buffer (single frame) with composited input frames
Transformed metadata (NvDsBatchMeta)
Formats supported: NV12/RGBA

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvmultistreamtiler plugin
Feature
Description
Release
Composites a 2D tile of input buffers
DS 2.0
Scales bounding box with metadata coordinates according to scaling and position in tile
DS 2.0
Multi-GPU support
DS 2.0
Shows expanded preview for a single source
DS 2.0
User configurable CUDA memory type (Pinned/Device/Unified) for output buffers
DS 3.0
Reconfigures 2D tile for new sources added at runtime
DS 3.0

Gst Properties

The following table describes the Gst-nvmultistreamtiler plugin’s Gst properties.
Gst-nvmultistreamtiler plugin, Gst properties
Property
Meaning
Type and Range
Example
Notes
rows
Number of rows in 2D tiled output
Integer,
1 to 4,294,967,295
row=2
columns
Number of columns in 2D tiled output
Integer,
1 to 4,294,967,295
columns=2
width
Width of 2D tiled output in pixels
Integer, 16 to 4,294,967,295
width=1920
height
Height of 2D tiled output in pixels
Integer, 16 to 4,294,967,295
height=1080
show-source
Scale and show frames from a single source.
-1: composite and show all sources
For values ≥0, frames from that source are zoomed.
Signed integer, −1 to 2,147,483,647
show-source=2
gpu-id
ID of the GPU on which device/unified memory is to be allocated, and in which buffers are copied or scaled. (dGPU only.)
Integer,
0 to 4,294,967,295
gpu-id=1
nvbuf-memory-type
Type of CUDA memory to be allocated.
For dGPU:
0 (nvbuf-mem-default): Default memory, cuda-device
1 (nvbuf-mem-cuda-pinned): Pinned/Host CUDA memory
2 (nvbuf-mem-cuda-device) Device CUDA memory
3 (nvbuf-mem-cuda-unified): Unified CUDA memory
For Jetson:
0 (nvbuf-mem-default): Default memory, surface array
4 (nvbuf-mem-surface-array): Surface array memory
Integer, 0-4
nvbuf-memory-type=1
custom-tile-config
Custom tile position and resolution. Can be configured programmatically for all or none of the sources.
Values of enum CustomTileConfig
Reserved for future use.
Default: null.

Gst-nvdsosd

This plugin draws bounding boxes, text, and region of interest (RoI) polygons. (Polygons are presented as a set of lines.)
The plugin accepts an RGBA buffer with attached metadata from the upstream component. It draws bounding boxes, which may be shaded depending on the configuration (e.g. width, color, and opacity) of a given bounding box. It also draws text and RoI polygons at specified locations in the frame. Text and polygon parameters are configurable through metadata.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
RGBA buffer
NvDsBatchMeta (holds NvDsFrameMeta consisting of bounding boxes, text parameters, and lines parameters)
NvDsLineMeta (RoI polygon)
Control parameters
gpu-id (dGPU only)
display-clock
display-text
clock-font
clock-font-size
x-clock-offset
y-clock-offset
clock-color
process-mode
hw-blend-color-attr
display-bbox
display-mask
Output
RGBA buffer modified in place to overlay bounding boxes, texts, and polygons represented in the metadata

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvdsosd plugin
Feature
Description
Release
Supports drawing arrows
Arrows can be drawn by specifying values in NvOSD_ArrowParams in metadata.
DS 5.0
Supports drawing circles
Circles can be drawn by specifying values in NvOSD_CircleParams in metadata.
DS 5.0
Support for blending bounding boxes
Blending boxes can be drawn by specifying bg_color values in NvOSD_RectParams in metadata. For HW mode, hw-blend-color-attr property for OSD needs to be set for blending.
DS 4.0
Supports drawing polygon lines
Lines can be drawn by specifying values in NvOSD_LineParams in metadata.
DS 3.0
Supports drawing text using Pango and Cairo libraries
Text can be drawn by specifying values in NvOSD_TextParams in metadata.
DS 2.0
VIC (Jetson only) and GPU support for drawing bounding boxes
Bounding boxes can be drawn by specifying values in NvOSD_RectParams in metadata.
DS 2.0

Gst Properties

The following table describes the Gst properties of the Gst-nvdsosd plugin.
Gst-nvdsosd plugin, Gst Properties
Property
Meaning
Type and Range
Example
Notes
gpu-id
Device ID of the GPU to be used for operation (dGPU only)
Integer,
0 to 4,294,967,295
gpu-id=0
display-clock
Indicates whether to display system clock
Boolean
display-clock=0
display-text
Indicates whether to display text
Boolean
display-text=0
clock-font
Name of Pango font to use for the clock
String
clock-font=Arial
clock-font-size
Font size to use for the clock
Integer, 0-60
clock-font-size=2
x-clock-offset
X offset of the clock
Integer,
0 to 4,294,967,295
x-clock-offset=100
y-clock-offset
Y offset of the clock
Integer,
0 to 4,294,967,295
y-clock-offset=50
clock-color
Color of the clock to be set while display, in the order
0xRGBA
Integer,
0 to 4,294,967,295
clock-color=0xff0000ff
(Clock is red with alpha=1)
process-mode
Indicates the mode used to draw the objects
0: CPU mode
1: GPU mode (For dGPU only)
2. VIC mode (For Jetson only)
Integer, 0 to 2
process-mode=0
hw-blend-color-attr
Blending color attributes for all classes. To be used for process-mode=2 (VIC based blending). If this property is set, shaded bboxes will be drawn using blending.
Property to be set in the form: “Class_ID,R,G,B,A” for each class separated by a “:”
Only applicable on Jetson.
Note that for HW mode, this property must be set , otherwise objects will not be blended with required colors.
String
hw-blend-color-attr=0,0.0,1.0,0.0,0.3:1,1.0,0.0,0.3.0.3
display-bbox
Control bounding box drawing
Boolean
display-bbox=1
display-mask
Controls instance mask drawing
Boolean
display-mask=1

Gst-nvvideoconvert

This plugin performs video color format conversion. It accepts NVMM memory as well as RAW (memory allocated using calloc() or malloc() ), and provides NVMM or RAW memory at the output.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
Gst Buffer batched buffer
NvDsBatchMeta
Format: NV12, I420, P010_10LE, BGRx, RGBA (NVMM/RAW)
Control parameters
gpu-id (dGPU only)
nvbuf-memory-type
src-crop
dst-crop
interpolation-method
compute-hw
Output
Gst Buffer
NvDsBatchMeta
Format: NV12, I420, P010_10LE, BGRx, RGBA (NVMM/RAW)

Features

This plugin supports scaling and conversion for NVMM to NVMM, RAW to NVMM, and NVMM to RAW and RAW to RAW buffer type conversion. The plugin supports cropping of the input and output frames.

Gst Properties

The following table describes the Gst properties of the Gst-nvvideoconvert plugin.
Gst-nvvideoconvert plugin, Gst Properties
Property
Meaning
Type and Range
Example
Notes
nvbuf-memory-type
Type of memory to be allocated.
For dGPU:
0 (nvbuf-mem-default): Default memory, cuda-device
1 (nvbuf-mem-cuda-pinned): Pinned/Host CUDA memory
2 (nvbuf-mem-cuda-device) Device CUDA memory
3 (nvbuf-mem-cuda-unified): Unified CUDA memory
For Jetson:
0 (nvbuf-mem-default): Default memory, surface array
4 (nvbuf-mem-surface-array): Surface array memory
enum GstNvVidConvBufMemoryType
 
src-crop
Pixel location: left:top:width:height
String
20; 40; 150; 100
dst-crop
Pixel location: left:top:width:height
String
20; 40; 150; 100
interpolation-method
Interpolation method.
0: Nearest
1: Bilinear
2: Algo-1 (GPU—Cubic, VIC—5 Tap)
3: Algo-2 (GPU—Super, VIC—10 Tap)
4: Algo-3 (GPU—LanzoS, VIC—Smart)
5: Algo-4 (GPU—Ignored, VIC—Nicest)
6: Default (GPU—Nearest, VIC—Nearest)
enum GstInterpolationMethod
interpolation-method=1
Default value is 6.
compute-hw
Type of computing hardware
0: Default (GPU for gDPU, VIC for Jetson)
1: GPU
2: VIC
enum GstComputeHW
compute-hw=0
Default value is 0.
gpu-id
Device ID of GPU to use for format conversion
Integer,
0 to 4,294,967,295
gpu-id=0
output-buffers
Number of Output Buffers for the buffer pool
Unsigned integer,
1 to 4,294,967,295
output-buffers=4

Gst-nvdewarper

This plugin dewarps camera input. It accepts gpu-id and config-file as properties. Based on the selected configuration of surfaces, it can generate a maximum of four dewarped surfaces. It currently supports dewarping of three projection types, NVDS_META_SURFACE_FISH_PUSHBROOM, NVDS_META_SURFACE_FISH_VERTCYL and NVDS_META_SURFACE_PERSPECTIVE_PERSPECTIVE. The first two are used in 360-D use case for dewarping 360° camera input.
The plugin performs its function in these steps:
1. Reads the configuration file and creates a vector of surface configurations. It supports a maximum of four dewarp surface configurations.
2. Receives the frame from the decoder; based on the configuration, generates up to four dewarped surfaces.
3. Scales these surfaces down to network/ selected dewarper output resolution using NPP APIs.
4. Pushes a buffer containing the dewarped surfaces to the downstream component.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
A buffer containing a frame in RGBA format
Control parameters
gpu-id; selects the GPU ID (dGPU only)
config-file, containing the pathname of the dewarper configuration file
Output
Dewarped RGBA surfaces
NvDewarperSurfaceMeta with information associated with each surface (projection_type, surface_index, and source_id), and the number of valid dewarped surfaces in the buffer (num_filled_surfaces)

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvdewarper plugin
Feature
Description
Release
Configure number of dewarped surfaces
Supports a maximum of four dewarper surfaces.
DS 3.0
Configure per-surface projection type
Currently supports FishPushBroom and FishVertRadCyd projections.
DS 3.0
Configure per-surface projection type
PerspectivePerspective projections
DS 5.0
Configure per-surface index
Surface index to be set in case of multiple surfaces having same projection type.
DS 3.0
Configure per-surface width and height
 
DS 3.0
Configure per-surface dewarping parameters
Per surface configurable yaw, roll, pitch, top angle, bottom angle, and focal length and CUDA address mode dewarping parameters.
For PerspectivePerspective projection type, field of view, distortion and principal point can additionally be configured.
DS 3.0
Configurable dewarper output resolution
Creates a batch of up to four surfaces of a specified output resolution; internally scales all dewarper surfaces to output resolution.
DS 3.0
Configurable NVDS CUDA memory type
DS 3.0
Multi-GPU support
DS 3.0
Aisle view CSV calibration file support
If set, properties in the [surface<n>] group are ignored.
Only supported for FishPushBroom and FishVertRadCyd.
DS 3.0
Spot view CSV calibration file support
If set, properties in the [surface<n>] group are ignored.
Only supported for FishPushBroom and FishVertRadCyd.
DS 3.0
Configure source id
Sets the source ID information in the NvDewarperSurfaceMeta.
DS 4.0
Configurable number of output buffers
Number of allocated output dewarper buffers. Each buffer contains four dewarped output surfaces.
DS 4.0
Configurable number of surfaces per output buffer
Number of dewarped output surfaces per buffer. Maximum allowed value is 4.
DS 5.0

Configuration File Parameters

The configuration file specifies per-surface configuration parameters in [surface<n>] groups, where <n> is an integer from 0 to 3, representing dewarped surfaces 0 to 3.
Gst-nvdewarper plugin, configuration file, [surface<n>] parameters
Property
Property Type
Meaning
Type and Range
Example
Notes
output-width
Global
Scale dewarped surfaces to specified output width
Integer, >0
output-width=960
output-height
Global
Scale dewarped surfaces to specified output height
Integer, >0
output-height=752
dewarp-dump-frames
Global
Number of dewarped frames to dump.
Integer, >0
dewarp-dump-frames=10
num-batch-buffers
Global
Number of dewarped output surfaces per buffer, i.e batch-size of the buffer.
Integer,
0 to 4
num-batch-buffers=4
projection-type
Global
Selects projection type. Supported types are:
1: PushBroom
2: VertRadCyl
3: PerspectivePerspective
Integer, 1 2 or 3
projection-type=1
surface-index
Surface
An index that distinguishes surfaces of the same projection type.
Integer, ≥0
surface-index=0
width
Surface
Dewarped surface width.
Integer, >0
width=3886
height
Surface
Dewarped surface height.
Integer, >0
height=666
top-angle
Surface
Top field of view angle, in degrees.
Float,
−180.0 to 180.0
top-angle=0
bottom-angle
Surface
Bottom field of view angle, in degrees.
Float,
−180.0 to 180.0
bottom-angle=0
pitch
Surface
Viewing parameter pitch in degrees.
Float,
0.0 to 360.0
pitch=90
yaw
Surface
Viewing parameter yaw in degrees.
Float,
0.0 to 360.0
yaw=0
roll
Surface
Viewing parameter roll in degrees.
Float,
0.0 to 360.0
roll=0
focal-length
Surface
Focal length of camera lens, in pixels per radian.
Float, >0.0
focal-length=437
src-fov
Surface
Source vertical field of view in degrees. Used to compute the source focal-length if the latter is not provided.
 
Only supported for PerspectivePerspective projection type.
Float, >0.0
src-fov=180
distortion
Surface
Distortion coefficients in the distortion
polynomial for a perspective source:
Three radial coefficients
():
Two tangential coefficients ():
 
Only supported for PerspectivePerspective projection type.
Array of floats
distortion=-0.3721;0.1023;-0.00203;0;0
 
distortion=
If not provided, all coefficients are set to 0 (no distortion)
src-x0
Surface
The X coordinate of the center of projection of the source image, in pixel coordinates.
Typically, it is (srcWidth-1)/2, but may be different if the image is calibrated or wraps around.
 
Only supported for PerspectivePerspective projection type.
 
Float, ≥0
src-x0=479.5
 
If not provided, will take its default value = (srcWidth-1)/2
src-y0
Surface
The Y coordinate of the center of projection of the source image, in pixel coordinates.
Typically, it is (srcHeight-1)/2, but may be different if the image is calibrated or wraps around.
 
Only supported for PerspectivePerspective projection type
 
 
Float, ≥0
src-y0=375.5
 
If not provided, will take its default value = (srcHeight-1)/2
 
cuda-address-mode
Surface
Cuda Texture addressing mode.
Currently supports:
0: cudaAddressModeClamp (Default) - sets points outside of border to nearest pixel value
1: cudaAddressModeBorder - sets points outside of border to transparent black
 
 
Integer, 0 or 1
cuda-address-mode=1
aisle-calibration-file
Global
Pathname of the configuration file for aisle view. Set for the 360‑D application only for PushBroom and/or VertRadCyl projection types.
If set, properties in the [surface<n>] group are ignored.
The configuration file is a CSV file with columns like sensorId and cameraId, and dewarping parameters like top-angle, bottom-angle, yaw, roll, pitch, focal-length, width, and height.
String
aisle-calibration-file=csv_files/nvaisle_2M.csv
 
spot-calibration-file
Global
Pathname of the configuration file for spot view. Set for the 360‑D application only for PushBroom and/or VertRadCyl projection types.
If set, properties in the [surface<n>] group are ignored.
The configuration file is a CSV file with columns like sensorId and cameraId, and dewarping parameters like top-angle, bottom-angle, yaw, roll, pitch, focal-length, width, and height.
String
spot-calibration-file=csv_files/nvspot_2M.csv
For an example of a spot view configuration file, see the file in the example above.
 
Note:
For the PerspectivePerspective projection type, in case viewing angles (top & bottom) are not provided, the destination center of projection (Principal Point) and Focal Length are kept the same as the source.
To increase the flexibility, num-batch-buffers is also a GstProperty. The plugin properties are parsed in order, so if num-batch-buffers is passed both attached to the GstElement in the gstreamer pipeline (eg. with gst-launch-1.0 command), and in the configuration file, the latest configuration applied will be used (see example below).
Example:
Config file (config_dewarper.txt) with “num-batch-buffers=2”.
Command Line argument with property “num-batch-buffers=1”.
Pipelines:
gst-launch-1.0 … ! nvdewarper config-file=config_dewarper.txt num-batch-buffers=1 ! …
gst-launch-1.0 … ! nvdewarper num-batch-buffers=1 config-file=config_dewarper.txt ! …
Pipeline 1 will result in 1 surface per buffer whereas pipeline 2 will result in 2 surfaces per buffer.
 
 
This plugin can be tested with the one of the following pipelines.
For dGPU:
gst-launch-1.0 filesrc location=streams/sample_cam6.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! nvdewarper config-file=config_dewarper.txt source-id=6 nvbuf-memory-type=3 ! m.sink_0 nvstreammux name=m width=960 height=752 batch-size=4 num-surfaces-per-frame=4 ! nvmultistreamtiler ! nveglglessink
Perspective Projection use-case:
gst-launch-1.0 filesrc location=streams/yoga.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! nvdewarper config-file=config_dewarper_perspective.txt nvbuf-memory-type=3 ! m.sink_0 nvstreammux name=m width=3680 height=2428 batch-size=1 num-surfaces-per-frame=1 ! nvmultistreamtiler ! nveglglessink
For Jetson:
gst-launch-1.0 filesrc location= streams/sample_cam6.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! nvdewarper config-file=config_dewarper.txt source-id=6 ! m.sink_0 nvstreammux name=m width=960 height=752 batch-size=4 num-surfaces-per-frame=4 ! nvmultistreamtiler ! nvegltransform ! nveglglessink
Perspective Projection use-case:
gst-launch-1.0 filesrc location=streams/yoga.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! nvdewarper config-file=config_dewarper_perspective.txt nvbuf-memory-type=3 ! m.sink_0 nvstreammux name=m width=3680 height=2428 batch-size=1 num-surfaces-per-frame=1 ! nvmultistreamtiler ! nvegltransform ! nveglglessink
Image File example dGPU:
gst-launch-1.0 filesrc location=streams/yoga.jpg ! nvjpegdec ! nvdewarper config-file=config_dewarper_perspective.txt ! nvvideoconvert ! jpegenc ! filesink location=output.jpg
Image File example Jetson:
gst-launch-1.0 filesrc location=streams/yoga.jpg ! nvjpegdec ! nvvideoconvert ! nvdewarper config-file=config_dewarper_perspective.txt ! nvvideoconvert ! jpegenc ! filesink location=output.jpg
To better see the effect of cuda-address-mode you can change the dewarping size. For example, in config_dewarper_perspective.txt change [surface0] parameters to:
width=7360
height=4856
cuda-address-mode=1
 
The Gst-nvdewarper plugin always outputs a GStreamer buffer which contains the number of dewarped surfaces defined by num-batch-buffers (currently maximum of four surfaces are supported). These dewarped surfaces are scaled to the output resolution (output-width × output-height) set in the configuration file located at configs/deepstream-app/config_dewarper.txt.
Also, the num-surfaces-per-frame and batch-size of Gst-nvstreammux must be set accordingly. Batch-size must be a multiple of the number of dewarped surfaces, which should be set in num-surfaces-per-frame.

Gst Properties

The following table describes the Gst-nvdewarper plugin’s Gst properties.
Gst-nvdewarper plugin, Gst properties
Property
Meaning
Type and Range
Example and
Notes
config-file
Absolute pathname of configuration file for the Gst-nvdewarper element
String
config-file= configs/ deepstream-app/ config_dewarper.txt
gpu-id
Device ID of the GPU to be used (dGPU only)
Integer,
0 to 4,294,967,295
gpu-id=0
source-id
Source ID, e.g. camera ID
Integer,
0 to 4,294,967,295
source-id=6
num-output-buffers
Number of output buffers to be allocated
Integer,
0 to 4,294,967,295
num-output-buffers=4
num-batch-buffers
Number of dewarped output surfaces per buffer, i.e., batch-size of the buffer
Integer,
0 to 4
num-batch-buffers=4
nvbuf-memory-type
Type of memory to be allocated.
For dGPU:
0 (nvbuf-mem-default): Default memory, cuda-device
1 (nvbuf-mem-cuda-pinned): Pinned/Host CUDA memory
2 (nvbuf-mem-cuda-device) Device CUDA memory
3 (nvbuf-mem-cuda-unified): Unified CUDA memory
For Jetson:
0 (nvbuf-mem-default): Default memory, surface array
4 (nvbuf-mem-surface-array): Surface array memory
Integer, 0 to 4
nvbuf-memory-type=3

Gst-nvof

NVIDIA GPUs, starting with the dGPU Turing generation and Jetson Xavier generation, contain a hardware accelerator for computing optical flow. Optical flow vectors are useful in various use cases such as object detection and tracking, video frame rate up-conversion, depth estimation, stitching, and so on.
The Gst-nvof plugin collects a pair of NV12 images and passes it to the low-level optical flow library. The low-level library returns a map of flow vectors between the two frames as its output.
The map of flow vectors is encapsulated in the NvDsOpticalFlowMeta structure and is added as a user meta with meta_type set to NVDS_OPTICAL_FLOW_META. The user meta is added to the frame_user_meta_list member of NvDsFrameMeta.
For guidance on how to access user metadata, see User/Custom Metadata Addition Inside NvDsMatchMeta and Tensor Metadata.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
GStreamer buffer containing NV12 frame(s)
Control parameters
gpu-id: selects the GPU ID (valid only for dGPU platforms)
dump-of-meta: enables dumping of optical flow map vector into a .bin file
preset-level: sets the preset level
pool-size: sets the pool size
grid-size: sets the grid size
Outputs
GStreamer buffer containing NV12 frame(s)
NvDsOpticalFlowMeta metadata

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvof plugin
Feature
Description
Release
Configure GPU selection
Sets the gpu ID to be used for optical flow operation (valid only for dGPU platforms)
DS 4.0
Configure dumping of optical flow metadata
Enables dumping of optical flow output (motion vector data)
DS 4.0
Configure preset level
Sets the desired preset level
DS 4.0
Configure grid size
Sets the flow vector block size
DS 4.0

Gst Properties

The following table describes the Gst properties of the Gst-nvof plugin.
Gst-nvof plugin, Gst properties
Property
Meaning
Type and Range
Example
Notes
gpu-id
Device ID of the GPU to be used for decoding (dGPU only).
Integer,
0 to 4,294,967,295
gpu-id=0
dump-of-meta
Dumps optical flow output into a .bin file.
Boolean
dump-of-meta=1
preset-level
Selects a preset level, default preset level is 0 i.e. NV_OF_PERF_LEVEL_FAST
Possible values are:
0 (NV_OF_PERF_LEVEL_FAST): high performance, low quality.
1 (NV_OF_PERF_LEVEL_MEDIUM): intermediate performance and quality.
2 (NV_OF_PERF_LEVEL_SLOW): low performance, best quality (valid only for dGPU platforms).
Enum, 0 to 2
preset-level=0
grid-size
Selects the grid size. The hardware generates flow vectors blockwise, one vector for each block of 4×4 pixels. Currently only the 4x4 grid size is supported.
Enum, 0
grid-size=0
pool-size
Sets the number of internal motion vector output buffers to be allocated.
Integer,
1 to 4,294,967,295
pool-size=7

Gst-nvofvisual

The Gst-nvofvisual plugin is useful for visualizing motion vector data. The visualization method is similar to the OpenCV reference source code in:
The plugin solves the optical flow problem by computing the magnitude and direction of optical flow from a two-channel array of flow vectors. It then visualizes the angle (direction) of flow by hue and the distance (magnitude) of flow by value of Hue Saturation Value (HSV) color representation. The strength of HSV is always set to a maximum of 255 for optimal visibility.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
GStreamer buffer containing NV12/RGBA frame(s)
NvDsOpticalFlowMeta containing the motion vector (MV) data generated by the gst-nvof plugin
Control parameters
gpu-id, selects the GPU ID
Output
GStreamer buffer containing RGBA frame(s)
RGBA buffer generated by transforming MV data into color-coded RGBA image reference

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvofvisual plugin
Feature
Description
Release
Configure GPU selection
Sets the GPU ID to be used for optical flow visualization operations (valid only for dGPU platforms)
DS 4.0

Gst Properties

The following table describes the Gst properties of the Gst-nvofvisual plugin.
Gst-nvofvisual plugin, Gst Properties
Property
Meaning
Type and Range
Example
Notes
gpu-id
Device ID of the GPU to be used
(dGPU only)
Integer,
0 to 4,294,967,295
gpu-id=0

Gst-nvsegvisual

The Gst-nvsegvisual plugin visualizes segmentation results. Segmentation is based on image recognition, except that the classifications occur at the pixel level as opposed to the image level as with image recognition. The segmentation output size is generally same as the input size.
For more information, see the segmentation training reference at:
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
GStreamer buffer containing NV12/RGBA frame(s)
NvDsInferSegmentationMeta containing class numbers, pixel class map, width, height, etc. generated by Gst-nvinfer.
gpu-id: selects the GPU ID
width, set according the segmentation output size
height, set according the segmentation output size
Output
This plugin allocates different colors for different classes. For example, the industrial model’s output has only one representing defective areas. Thus, defective areas and background have different colors. The semantic model outputs four classes with four different colors: car, pedestrian, bicycle, and background.
This plugin shows only the segmentation output. It does not overlay output on the original NV12 frame.
The following table summarizes the features of the plugin.
Features of the Gst-nvsegvisual plugin
Feature
Description
Release
Configure GPU selection
Sets the GPU ID to be used for segmentation visualization operations (valid only for dGPU platforms)
DS 4.0
Configure width
Sets width according to the segmentation output size
DS 4.0
Configure height
Sets height according to the segmentation output size
DS 4.0

Gst Properties

The following table describes the Gst properties of the Gst-nvsegvisual plugin.
Gst-nvsegvisual plugin, Gst Properties
Property
Meaning
Type and Range
Example and
Notes
gpu-id
Device ID of the GPU to be used for decoding
Integer,
0 to 4,294,967,295
gpu-id=0
width
Segmentation output width
Integer,
0 to 4,294,967,295
width=512
height
Segmentation output height
Integer,
0 to 4,294,967,295
height=512

Gst-nvvideo4linux2

DeepStream extends the open source V4L2 codec plugins (here called Gst-v4l2) to support hardware-accelerated codecs.
A screenshot of a cell phone Description automatically generated

Decoder

The OSS Gst-nvvideo4linux2 plugin leverages the hardware decoding engines on Jetson and DGPU platforms by interfacing with libv4l2 plugins on those platforms. It supports H.264, H.265, JPEG and MJPEG formats.
The plugin accepts an encoded bitstream and uses the NVDEC hardware engine to decode the bitstream. The decoded output is in NV12 format.
Note:
When you use the v4l2 decoder for decoding JPEG images, you must use the open source jpegparse plugin before the decoder to parse encoded JPEG images.

Inputs and Outputs

Inputs
An encoded bitstream. Supported formats are H.264, H.265, JPEG and MJPEG
Control Parameters
gpu-id
num-extra-surfaces
skip-frames
cudadec-memtype
drop-frame-interval
Output
Gst Buffer with decoded output in NV12 format

Features

The following table summarizes the features of the Gst-nvvideo4linux2 decoder plugin.
Features
Feature
Description
Release
Supports H.264 decode
DS 4.0
Supports H.265 decode
DS 4.0
Supports JPEG/MJPEG decode
_
DS 4.0
User-configurable CUDA memory type (Pinned/Device/Unified) for output buffers
DS 4.0

Gst Properties

The following table summarizes the Gst properties of the Gst-nvvideo4linux2 decoder plugin.
Property
Meaning
Type and Range
Example
Notes
Platforms
gpu-id
Device ID of GPU to use for decoding.
Integer,
0 to 4,294,967,295 
gpu-id=0
dGPU
num-extra-surfaces
Number of surfaces in addition to min decode surfaces given by the V4L2 driver.
Integer, 1 to 24
num-decode-surfaces=24
Default: 0
dGPU
Jetson
skip-frames
Type of frames to skip during decoding. Represented internally by enum SkipFrame.
0 (decode_all): decode all frames
1 (decode_non_ref): decode non-ref frames
2 (decode_key): decode key frames
Integer,
0, 1, or 2
skip-frames=0
Default: 0
dGPU
Jetson
drop-frame-interval
Interval to drop the frames, e.g. a value of 5 means the decoder receives every fifth frame, and others are dropped.
Integer,
1 to 30
Default: 0
dGPU
Jetson
cudadec-memtype
Memory type for CUDA decoder buffers. Represented internally by enum CudaDecMemType.
0 (memtype_device): Device
1 (memtype_pinned): Host Pinned
2 (memtype_unified): Unified
Integer,
0, 1, or 2
cuda-memory-type=1
Default: 2
dGPU

Encoder

The OSS Gst-nvvideo4linux2 plugin leverages the hardware accelerated encoding engine available on Jetson and dGPU platforms by interfacing with libv4l2 plugins on those platforms. The plugin accepts RAW data in I420 format. It uses the NVENC hardware engine to encode RAW input. Encoded output is in elementary bitstream supported format.

Inputs and Outputs

Inputs
RAW input in I420 format
Control parameters
gpu-id (dGPU only)
profile
bitrate
control-rate
iframeinterval
Output
Gst Buffer with encoded output in H264 and H265 format.

Features

The following table summarizes the features of the Gst-nvvideo4linux2 encoder plugin.
Feature
Description
Release
Supports H.264 encode
DS 4.0
Supports H.265 encode
DS 4.0

Gst Properties

The following table summarizes the Gst properties of the Gst-nvvideo4linux2 encoder plugin.
Property
Meaning
Type and Range
Example
Notes
Platforms
gpu-id
Device ID of GPU to used.
Integer,
0 to 4,294,967,295
gpu-id=0
dGPU
bitrate
Sets bitrate for encoding, in bits/seconds.
Integer,
0 to 4,294,967,295
Default:4000000
dGPU
Jetson
iframeinterval
Encoding intra-frame occurrence frequency.
Unsigned integer,
0 to 4,294,967,295
Default: 30
dGPU
Jetson
Profile
H.264/H.265 encoder profile; represented internally by enum GstV4l2VideoEncProfileType.
For H.264:
0 (GST_V4L2_H264_VIDENC_BASELINE_PROFILE): Baseline
2 (GST_V4L2_H264_VIDENC_MAIN_PROFILE): Main
4 (GST_V4L2_H264_VIDENC_HIGH_PROFILE): High
For H.265:
0 (GST_V4L2_H265_VIDENC_MAIN_PROFILE): Main
1 (GST_V4L2_H265_VIDENC_MAIN10_PROFILE): Main10
Values of enum GstV4l2VideoEncProfileType
Default Baseline
Default: 0
dGPU
Jetson

Gst-nvjpegdec

The Gst-nvjpegdec plugin decodes images on both dGPU and Jetson platforms. It is the preferred method for decoding JPEG images.
On the dGPU platform this plugin is based on the libnvjpeg library, part of the CUDA toolkit. On Jetson it uses a platform-specific hardware accelerator.
The plugin uses an internal software parser to parse JPEG streams. Thus, there is no need to use a jpegparse open source plugin separately to parse the encoded frame.
The plugin accepts a JPEG encoded bitstream and produces RGBA output on the dGPU platform and produces I420 output on the Jetson platform.

Inputs and Outputs

Inputs
Elementary JPEG
Control parameters
gpu-id (dGPU only)
DeepStream (Jetson only)
Output
Gst Buffer with decoded output in RGBA format

Features

The following table summarizes the features of the Gst-nvjpegdec plugin.
Feature
Description
Release
Supports JPEG Decode
DS 4.0
Supports MJPEG Decode
DS 4.0

Gst Properties

The following table summarizes the Gst properties of the Gst-nvjpegdec plugin.
Property
Meaning
Type and Range
Example and
Notes
Platforms
gpu-id
Device ID of GPU to use for decoding.
Integer,
0 to 4,294,967,295 
gpu-id=0
dGPU
DeepStream
Applicable only for Jetson; required for outputting buffer with new NvBufSurface or Legacy Buffer
Boolean
DeepStream=1
Jetson

Gst-nvmsgconv

The Gst-nvmsgconv plugin parses NVDS_EVENT_MSG_META (NvDsEventMsgMeta) type metadata attached to the buffer as user metadata of frame meta and generates the schema payload. For the batched buffer, metadata of all objects of a frame must be under the corresponding frame meta.
The generated payload (NvDsPayload) is attached back to the input buffer as NVDS_PAYLOAD_META type user metadata.
DeepStream 5.0 supports two variations of the schema, full and minimal. The Gst-nvmsgconv plugin can be configured to use either one of the schemas.
By default, the plugin uses the full DeepStream schema to generate the payload in JSON format. The full schema supports elaborate semantics for object detection, analytics modules, events, location, and sensor. Each payload has information about a single object.
You can use the minimal variation of the schema to communicate minimal information with the back end. This provides a small footprint for the payload to be transmitted from DeepStream to a message broker. Each payload can have information for multiple objects in the frame.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
Gst Buffer with NvDsEventMsgMeta
Control parameters
config
msg2p-lib
payload-type
comp-id
Output
Same Gst Buffer with additional NvDsPayload metadata. This metadata contains information about the payload generated by the plugin.

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvmsgconv plugin
Feature
Description
Release
Payload in JSON format
Message payload is generated in JSON format
DS 3.0
Supports DeepStream schema specification
DeepStream schema spec implementation for messages
DS 3.0
Custom schema specification
Provision for custom schemas for messages
DS 3.0
Key-value file parsing for static properties
Read static properties of sensor/place/module in the form of key-value pair from a text file
DS 3.0
CSV file parsing for static properties
Read static properties of sensor/place/module from a CSV file
DS 3.0
DeepStream 4.0.1 minimalistic schema
Minimal variation of the DeepStream message schema
DS 4.0

Gst Properties

The following table describes the Gst-nvmsgconv plugin’s Gst properties.
Gst-nvmsgconv plugin, Gst properties
Property
Meaning
Type and Range
Example
Notes
Platforms
config
Absolute pathname of a configuration file that defines static properties of various sensors, places, and modules.
String
config=msgconv_config.txt
or
config=msgconv_config.csv
dGPU
Jetson
msg2p-lib
Absolute pathname of the library containing a custom implementation of the nvds_msg2p_* interface for custom payload generation.
String
msg2p-lib=libnvds_msgconv_custom.so
dGPU
Jetson
payload-type
Type of schema payload to be generated. Possible values are:
PAYLOAD_DEEPSTREAM: Payload using DeepStream schema.
PAYLOAD_DEEPSTREAM_MINIMAL: Payload using minimal DeepStream schema.
PAYLOAD_CUSTOM: Payload using custom schemas.
Integer,
0 to 4,294,967,295
payload-type=0
or
payload-type=257
dGPU
Jetson
comp-id
Component ID of the plugin from which metadata is to be processed.
Integer,
0 to 4,294,967,295
comp-id=2
Default is NvDsEventMsgMeta
dGPU
Jetson

Schema Customization

This plugin can be used to implement a custom schema in two ways:
By modifying the payload generator library: To perform a simple customization of DeepStream schema fields, modify the low-level payload generation library file sources/libs/nvmsgconv/nvmsgconv.cpp.
By implementing the nvds_msg2p interface: If a library that implements the custom schema needs to be integrated with the DeepStream SDK, wrap the library in the nvds_msg2p interface and set the plugin’s msg2p-lib property to the library’s name. Set the payload-type property to PAYLOAD_CUSTOM.
See sources/libs/nvmsgconv/nvmsgconv.cpp for an example implementation of the nvds_msg2p interface.

Payload with Custom Objects

You can add a group of custom objects to the NvDsEventMsgMeta structure in the extMsg field and specify their size in the extMsgSize field. The meta copy (copy_func) and free (release_func) functions must handle the custom fields accordingly.
The payload generator library handles some standard types of objects (Vehicle, Person, Face, etc.) and generates the payload according to the schema selected. To handle custom object types, you must modify the payload generator library nvmsgconv.cpp.
See deepstream-test4 for details about adding custom objects as NVDS_EVENT_MSG_META user metadata with buffers for generating a custom payload to send to back end.

Gst-nvmsgbroker

This plugin sends payload messages to the server using a specified communication protocol. It accepts any buffer that has NvDsPayload metadata attached and uses the nvds_msgapi_* interface to send the messages to the server. You must implement the nvds_msgapi_* interface for the protocol to be used and specify the implementing library in the proto-lib property.
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
Gst Buffer with NvDsPayload
Control parameters
Config
conn-str
proto-lib
comp-id
topic
Output
None, as this is a sink component

Features

The following table summarizes the features of the Gst-nvmsgbroker plugin.
Features of the Gst-nvmsgbroker plugin
Feature
Description
Release
Payload in JSON format
Accepts message payload in JSON format
DS 3.0
Kafka protocol support
Kafka protocol adapter implementation
DS 3.0
Azure IOT support
Integration with Azure IOT framework
DS 4.0
AMQP support
AMQP 0-9-1 protocol adapter implementation
DS 4.0
Custom protocol support
Provision to support custom protocol through a custom implementation of the adapter interface
DS 3.0
Configurable parameters
Protocol specific options through configuration file
DS 3.0

Gst Properties

The following table describes the Gst properties of the Gst-nvmsgbroker plugin.
Gst-nvmsgbroker plugin, Gst Properties
Property
Meaning
Type and Range
Example
Notes
Platforms
config
Absolute pathname of configuration file required by nvds_msgapi_* interface
String
config=<msgapi_config.txt>
dGPU
Jetson
conn-str
Connection string as end point for communication with server
String
Format must be <name>;<port>;<specifier>
conn-str=foo.bar.com;80
;user-id
dGPU
Jetson
proto-lib
Absolute pathname of library that contains the protocol adapter as an implementation of nvds_msgapi_*
String
proto-lib=<libnvds_kafka_proto.so>
dGPU
Jetson
comp-id
ID of component from which metadata should be processed
Integer,
0 to 4,294,967,295
comp-id=3
Default: plugin processes metadata from any component
dGPU
Jetson
topic
Message topic name
String
topic=dsapp1
dGPU
Jetson
subscribe-topic-list
Topic names to subscribe for consuming messages
String
subscribe-topic-list=topic1; topic2; topic3
dGPU
Jetson
new-api
To use protocol adapter library apis directly or use new msgbroker library wrapper apis
Integer
0 : Use adapter api’s directly
1 : msgbroker lib wrapper api’s
new-api = 0
 
dGPU
Jetson

nvds_msgapi: Protocol Adapter Interface

You can use the DeepStream messaging interface, nvds_msgapi, to implement a custom protocol message handler and integrate it with DeepStream applications. Such a message handler, known as a protocol adapter, enables you to integrate DeepStream applications with backend data sources, such as data stored in the cloud.
A screenshot of a cell phone Description automatically generated
The Gst-nvmsgbroker plugin calls the functions in your protocol adapter as shown in the figure above. These functions support:
Creating a connection
Sending messages by synchronous or asynchronous means
Terminating the connection
Coordinating the client’s and protocol adapter’s use of CPU resources and threads
Getting the protocol adapter’s version number
The nvds_msgapi interface is defined in the header file source/includes/nvds_msgapi.h. This header file defines a set of function pointers which provide an interface analogous to an interface in C++.
The following sections describe the methods defined by the nvds_msgapi interface.

nvds_msgapi_connect(): Create a Connection

NvDsMsgApiHandle nvds_msgapi_connect(char *connection_str,
nvds_msgapi_connect_cb_t connect_cb, char *config_path
);
The function accepts a connection string and configures a connection. The adapter implementation can choose whether the function makes a connection to accommodate connectionless protocols such as HTTP.
Parameters
connection_str: A pointer to a string that specifies connection parameters in the general format "<url>;<port>;<specifier>".
<url> and <port> specify the network address of the remote entity.
<specifier> specifies information specific to a protocol. Its content depends on the protocol’s implementation. It may be, for example, a client identifier for making the connection.
Note that this connection string format is not binding, and an adapter may omit some fields (e.g.: specifier) from its format, provided the omission is described in its documentation.
A special case of such connection string adaptation is where the adapter expects all connection parameters to be specified as fields in the configuration file (see config path below), in which case the connection string is passed as NULL.
connect_cb: A callback function for events associated with the connection.
config_path: The pathname of a configuration file that defines protocol parameters used by the adapter.
Return Value
A handle for use in subsequent interface calls if successful, or NULL otherwise.

nvds_msgapi_send() and nvds_msgapi_send_async(): Send an event

NvDsMsgApiErrorType nvds_msgapi_send(NvDsMsgApiHandle *h_ptr,
char *topic, uint8_t *payload, size_t nbuf
);
 
NvDsMsgApiErrorType nvds_msgapi_send_async(NvDsMsgApiHandle h_ptr,
char *topic, const uint8_t *payload, size_t nbuf,
nvds_msgapi_send_cb_t send_callback, void *user_ptr
);
Both functions send data to the endpoint of a connection. They accept a message topic and a message payload.
The nvds_send() function is synchronous. The nvds_msgapi_send_async() function is asynchronous; it accepts a callback function that is called when the “send” operation is completed.
Both functions allow the API client to control execution of the adapter logic by calling nvds_msgapi_do_work(). See the description of the nvds_msgapi_do_work() function.
Parameters
h_ptr: A handle for the connection, obtained by a call to nvds_msgapi_connect().
topic: A pointer to a string that specifies a topic for the message; may be NULL if topic is not meaningful for the semantics of the protocol adapter.
payload: A pointer to a byte array that contains the payload for the message.
nbuf: Number of bytes to be sent.
send_callback: A pointer to a callback function that the asynchronous function calls when the “send” operation is complete. The signature of the callback function is of type nvds_msgapi_send_cb_t, defined as:
typedef void (*nvds_msgapi_send_cb_t)(void *user_ptr,
NvDsMsgApiErrorType completion_flag
);
Where the callback’s parameters are:
user_ptr: The user pointer (user_ptr) from the call to nvds_msgapi_send() or nvds_msgapi_send_async() that initiated the “send” operation. Enables the callback function to identify the initiating call.
completion_flag: A code that indicates the completion status of the asynchronous send operation.

nvds_msgapi_subscribe(): Consume data by subscribing to topics

NvDsMsgApiErrorType nvds_msgapi_subscribe (NvDsMsgApiHandle h_ptr, char ** topics, int num_topics, nvds_msgapi_subscribe_request_cb_t cb, void *user_ctx);
This API is used to subscribe to topic(s) and consume messages from the external entity.
The API is asynchronous and must be called with an already created valid Kafka connection handle as parameter. The caller must also provide a pointer to the callback function to receive the consumed messages from the connection endpoint and an optional user_ctx pointer for specifying user context
Parameters
h_ptr: A handle for the connection, obtained by a call to nvds_msgapi_connect()
topics: A 2d pointer which points to a char array of topic names
num_topics: num of topics to subscribe
cb: A pointer to a callback function to get notified of the consumed messages on subscribed topic(s)
user_ctx: user ptr to be passed to callback for context
The pointer to a callback function which is specified as a param in subscribe API is of type nvds_msgapi_subscribe_request_cb_t defined as:
typedef void (*nvds_msgapi_subscribe_request_cb_t)(NvDsMsgApiErrorType flag, void *msg, int msg_len, char *topic, void *user_ptr);
Where the callback’s parameters are:
flag: To specify the error status of message consumed
msg: Consumed message / payload
msg_len: Length of message in bytes
topic: Topic name where the message was received
user_ptr: pointer passed during subscribe() for context

nvds_msgapi_do_work(): Incremental Execution of Adapter Logic

void nvds_msgapi_do_work();
The protocol adapter must periodically surrender control to the client during processing of nvds_msgapi_send() and nvds_msgapi_send_async() calls. The client must periodically call nvsd_msgapi_do_work() to let the protocol adapter resume execution. This ensures that the protocol adapter receives enough CPU resources. The client can use this convention to control the protocol adapter’s use of multi-threading and thread scheduling. The protocol adapter can use it to support heartbeat functionality, if the underlying protocol requires that.
The nvds_msgapi_do_work() convention is needed when the protocol adapter executes in the client thread. Alternatively, the protocol adapter may execute time-consuming operations in its own thread. In this case the protocol adapter need not surrender control to the client, the client need not call nvsd_msgapi_do_work(), and the implementation of nvds_msgapi_do_work() may be a no-op.
The protocol adapter’s documentation must specify whether the client must call nvds_msgapi_do_work(), and if so, how often.

nvds_msgapi_disconnect(): Terminate a Connection

NvDsMsgApiErrorType nvds_msgapi_disconnect(NvDsMsgApiHandle h_ptr);
The function terminates the connection, if the underlying protocol requires it, and frees resources associated with h_ptr.
Parameters
h_ptr: A handle for the connection, obtained by a call to nvds_msgapi_connect().

nvds_msgapi_getversion(): Get Version Number

char *nvds_msgapi_getversion();
This function returns a string that identifies the nvds_msgapi version supported by this protocol adapter implementation. The string must use the format "<major>.<minor>", where <major> is a major version number and <minor> is a minor version number. A change in the major version number indicates an API change that may cause incompatibility. When the major version number changes, the minor version number is reset to 1.

nvds_msgapi_get_protocol_name(): Get name of the protocol

char *nvds_msgapi_get_protocol_name(void);
This function returns a string that identifies the underlying protocol used in the adapter library. Ex: "KAFKA”, “AMQP”, “AZURE_DEVICE_CLIENT” , “AZURE_MODULE_CLIENT”

nvds_msgapi_connection_signature(): Get Connection signature

NvDsMsgApiErrorType nvds_msgapi_connection_signature(char *broker_str, char *cfg, char *output_str, int max_len);
This function returns a string that uniquely identifies the signature of the connection parameters passed to the adapter library for making a connection. On success, a connection signature string(generated by SHA256) is returned. Upon error or invalid connection params, empty string “” is returned.
Parameters:
broker_str: Broker connection string used to create connection
cfg: Path to config file
output_str: Output Connection signature
max_len : max length of output_str

nvds_kafka_proto: Kafka Protocol Adapter

The DeepStream 5.0 release includes a protocol adapter that supports Apache Kafka. The adapter provides out-of-the-box capability for DeepStream applications to publish messages to Kafka brokers.

Installing Dependencies

The Kafka adapter uses librdkafka for the underlying protocol implementation. This library must be installed prior to use.
To install librdkakfa, enter these commands:
git clone https://github.com/edenhill/librdkafka.git
cd librdkafka
git reset --hard 7101c2310341ab3f4675fc565f64f0967e135a6a
./configure
make
sudo make install
sudo cp /usr/local/lib/librdkafka* /opt/nvidia/deepstream/deepstream-5.0/lib
Install additional dependencies:
sudo apt-get install libglib2.0 libglib2.0-dev
sudo apt-get install libjansson4 libjansson-dev

Using the Adapter

You can use the Kafka adapter in an application by setting the Gst-nvmsgbroker plugin’s proto-lib property to the pathname of the adapter’s shared library, libnvds_kafka_proto.so. The plugin’s conn-str property must be set to a string with format:
<kafka broker address>;<port>
This instantiates the Gst-nvmsgbroker plugin and makes it use the Kafka protocol adapter to publish messages that the application sends to the broker at the specified broker address and topic.

Configuring Protocol Settings

You can define configuration setting for the Kafka protocol adapter as described by the documentation at:
You can set these options in the Gst-nvmsgbroker configuration file. Like the rest of DeepStream, the configuration file uses the “gkey” format. The Kafka settings must be in a group named [message-broker] and must be specified as part of a key named proto-cfg. The settings can be a series of key-value pairs separated by semicolons. For example:
[message-broker]
proto-cfg="message.timeout.ms=2000;retries=5"
consumer-group-id = groupid
partition-key = keyid
The Kafka adapter lets you specify the name of the field in messages that is to be used to define the partition key. For each message, the specified message field is extracted and send to the topic partitioner along with the message. The partitioner uses it to identify the partition in the Kafka cluster that handles the message. The partition key information must be specified in the Gst-nvmsgbroker configuration file’s [message-broker] group, using an entry named partition-key.
Fields embedded in a hierarchy of JSON objects in the message are specified using dotted notation. For example, for the sample JSON message shown below, the id field in the sensor object is identified as sensor.id,
{
"sensor" {
"id": "cam1"
}
}
Additionally, the Kafka adapter lets you specify the consumer group id. The consumer group is a string that uniquely identifies the group of consumer processes to which this Kafka consumer belongs. The key name consumer-group-id can be specified in the Gst-nvmsgbroker configuration file’s [message-broker] group. If this field is unspecified, the default consumer group name "test-consumer-group" will be used.
Note:
For the DeepStream reference application and the 360‑D application, both distributed with the DeepStream SDK, you can add the proto-cfg setting to the [message-broker] group of the top-level configuration file passed to the application.

Programmatic Integration

You can integrate the Kafka adapter into custom user code by using the nvds_msgapi interface to call its functions. Note the following points regarding the functions defined by the interface:
The connection string passed to the nvdm_msgapi_connect() has the format <kafka broker address>;<port>.
For both “send” functions, the topic name must be passed as param to nvds_msgapi_send(). or nvds_msgapi_send_async()
For the subscribe API, a 2D pointer to a char array of topic-names must be passed as param. Also, a pointer to a user callback function must be provided. When there’s a new message from the remote entity, the Kafka consumer will forward the message to the application by calling the user callback function.
The application must call nvds_msgapi_do_work() at least once a second, and preferably more often. The frequency of calls to nvds_msgapi_do_work() determines the rate at which messages waiting to be sent are processed.
It is safe for multiple application threads to share connection handles. The library librdkafka is thread-safe, so Kafka protocol adapter does not need to implement separate locking mechanisms for functions calling directly to this library.
The Kafka protocol adapter expects the client to manage usage and retirement of the connection handle. The client must ensure that once a handle is disconnected, it is not used for either a “send” call or a call to nvds_msgapi_do_work(). While the library attempts to ensure graceful failure if the application calls these functions with retired handles, it does not do so in a thread-safe manner.

Security for Kafka

To learn more about security for Kafka, see the Secure Edge-to-Cloud messaging section in NVIDIA DeepStream SDK Developer Guide 5.0 Release.

Monitor Adapter Execution

The Kafka adapter generates log messages based on the nvds_logger framework to help you monitor execution. The adapter generates separate logs for the INFO, DEBUG, and ERROR severity levels, as described in nvds_logger: The Logger Framework. You can limit the log messages generated by setting the level at which log messages are filtered as part of the logging setup script.
Note:
If the severity level is set to DEBUG, the nvds_logger framework logs the entire contents of each message sent by the Kafka protocol adapter.

Azure MQTT Protocol Adapter Libraries

The DeepStream 5.0 release includes protocol adapters that supports direct messaging from device to cloud (using the Azure device client adapter) and through Azure IoT Edge runtime (using the Azure module client adapter). The adapters provide out-of-the-box capability for DeepStream applications to publish messages to Azure IoT Hub using the MQTT protocol.
The Azure IoT protocol adapters are encapsulated by their respective shared libraries found within the DeepStream package at the location:
/opt/nvidia/deepstream/deepstream-5.0/lib
The Azure device client adapter library is named libnvds_azure_proto.so.
The Azure module client adapter library is named libnvds_azure_edge_proto.so.

Installing Dependencies

Azure adapters use libiothub_client.so from the Azure IoT C SDK (v1.2.8) for the underlying protocol implementation. After you install the deepstream package you can find the precompiled library at:
/opt/nvidia/deepstream/deepstream-5.0/lib/libiothub_client.so
You can also compile libiothub_client.so manually by entering these commands:
git clone -b 2018-07-11 --recursive https://github.com/Azure/azure-iot-sdk-c.git
cd azure-iot-sdk-c
mkdir cmake
cd cmake
cmake ..
cmake --build . # append '-- -j <n>' to run <n> jobs in parallel
To install some other required dependencies, enter one of these commands.
For an x86 computer using Ubuntu 18.04:
sudo apt-get install -y libcurl3 libssl-dev uuid-dev libglib2.0 libglib2.0-dev
For other platforms or OS:
sudo apt-get install -y libcurl4-openssl-dev libssl-dev uuid-dev libglib2.0 libglib2.0-dev

Setting Up Azure IoT

Azure IoT adapter needs a functioning Azure IoT Hub instance to which is can publish messages. To set up an Azure IoT Hub instance if required, see the instructions at:
https://docs.microsoft.com/en-us/azure/iot-hub/tutorial-connectivity
After you create the Azure IoT instance, create a device entry corresponding to the device that is running DeepStream.
To set up Azure IoT Edge runtime on the edge device, see the instructions at:
https://docs.microsoft.com/en-us/azure/iot-edge/how-to-install-iot-edge-linux

Configuring Adapter Settings

Place Azure IoT specific information in a custom configuration file named, e.g., cfg_azure.txt. The entries in the configuration file vary slightly between the Azure device client and the module client.
For an Azure device client:
[message-broker]
connection_str = HostName=<my-hub>.azure-devices.net;DeviceId=<device_id>;
SharedAccessKey=<my-policy-key>
shared_access_key = <my-policy-key>
custom_msg_properties = <key1>=<value1>; <key2>=<value2>; <key3>=<value3>;
For an Azure module client:
[message-broker]
#custom_msg_properties = <key1>=<value1>; <key2>=<value2>; <key3>=<value3>;
Here is useful information about some of the configuration file properties:
connection_str: You can obtain the Azure connection string from the Azure IoT Hub web interface. A connection string uniquely identifies each device associated with the IoT Hub instance. It is under the “Primary Connection String” entry in the “Device detail” section.
shared_access_key: You can obtain the shared access key from the “Primary key” entry in the “Device detail” section.
custom_msg_properties: Use this property to embed custom key/value pairs in the MQTT messages sent from the device to Azure IoT. You can embed multiple key values separated by semicolons, as in this example:
custom_msg_properties = ex2: key1=value1;key2=value2;key3=value3;
Note:
The connection_str, shared_access_key, and custom_msg_properties strings are each limited to 512 characters.

Using the Adapter

To use the Azure device client adapter in an application, set the Gst-nvmsgbroker plugin’s proto-lib property to the pathname of the adapter’s shared library - libnvds_azure_proto.so for the device client case, or libnvds_azure_edge_proto.so for the module client case.
The next step in using the adapter is to specify the connection details. The procedure for specifying connection details is different for the Azure device client and module client cases, as described in the following sections.
Connection Details for the Device Client Adapter
Set the plugin’s conn-str property to the full Azure connection string in the format:
HostName=<my-hub>.azure-devices.net;DeviceId=<device_id>;SharedAccessKey=<my-policy-key>
Alternatively, you can specify the connection string details in the Azure configuration file:
[message-broker]
connection_str = HostName=<my-hub>.azure-devices.net;DeviceId=<device_id>;SharedAccessKey=<my-policy-key>
Connection Details for the Module Client Adapter
Leave the connection string empty, since the Azure IoT Edge library automatically fetches the connection string from the file /etc/iotedge/config.yaml.
Once the connection details have been configured, you can integrate the Azure device client and module client adapters into custom user code by using the nvds_msgapi interface to call its functions. Note the following points about the functions defined by the interface:
The connection string passed to nvds_msgapi_connect() may be NULL for both the Azure device client and the module client. For the device client the Azure configuration file has an option to specify a connection string. For the module client the connection string is always specified in /etc/iotedge/config.yaml.
Both “send” functions use the topic name specified in the Gst-nvmsgbroker plugin’s property “topic.” It may be null.
The application must call nvds_msgapi_do_work() after each call to nvds_msgapi_send_async(). The frequency of calls to nvds_msgapi_do_work() determines the rate at which messages waiting to be sent are processed.
It is safe for multiple application threads to share connection handles. The library libiothubclient is thread-safe, so Azure protocol adapters need not implement separate locking mechanisms for functions calling this library directly.
The Azure protocol adapters expects the client to manage usage and retirement of the connection handle. The client must ensure that once a handle is disconnected, it is not used for either a “send” call or a call to nvds_msgapi_do_work(). While the library attempts to ensure graceful failure if the application calls these functions with retired handles, it does not do so in a thread-safe manner.

Monitor Adapter Execution

The Azure device client and module client use different logging mechanisms.
Azure device client library log messages
The Azure device client adapter uses the nvds_logger framework to generate log messages which can help you monitor execution. The adapter generates separate logs for the INFO, DEBUG, and ERROR severity levels, as described in nvds_logger: Logging Framework. You can limit the generated log messages by setting the level at which log messages are filtered in the logging setup script.
Note:
If the severity level is set to DEBUG, the nvds_logger framework logs the entire contents of each message sent by the Azure device client protocol adapter.
Azure Module Client Library Log Messages
The log messages from the Azure module client adapter library are emitted to stdout, and the log output is captured in the docker/iotedge module logs.

Message Topics and Routes

You can specify a message topic in a GStreamer property topic. However, the Azure device client and module client use the topic property in different ways.
The Azure device client does not support topics. Thus, the value of the topic property is ignored, and you cannot use it to filter messages on Azure IoT Hub.
The Azure module client uses the topic property to determine the route of messages, i.e. how messages are passed within a system. For more information about message routes, see:
https://docs.microsoft.com/en-us/azure/iot-edge/module-composition#declare-routes)

AMQP Protocol Adapter

DeepStream release 5.0 includes an AMQP protocol adapter that DeepStream applications can use out of the box to publish messages using AMQP 0-9-1 message protocol.
The AMQP protocol adapter shared library is in the deepstream package at:
/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_amqp_proto.so

Installing Dependencies

AMQP protocol adapter for DeepStream uses the librabbitmq.so library, built from rabbitmq-c (v0.8.0) for the underlying AMQP protocol implementation. To build the library, enter these commands:
git clone -b v0.8.0 --recursive https://github.com/alanxz/rabbitmq-c.git
mkdir build && cd build
cmake ..
cmake --build .
To copy the built librabbitmq.so library to its final location, enter this command.
For x86:
sudo cp ./librabbitmq/librabbitmq.so.4 /usr/lib/
For Jetson:
sudo cp ./librabbitmq/librabbitmq.so.4 /usr/lib/aarch64-linux-gnu/
Install additional dependencies:
sudo apt-get install libglib2.0 libglib2.0-dev
AMQP broker
The AMQP protocol communicates with an AMQP 0-9-1 compliant message broker. If you do not have a functioning broker already, you can deploy one by installing the rabbitmq-server package, available at:
You can install this package on your local system or on the remote machine where you want the broker to be installed.
To install the package, enter the command:
sudo apt-get install rabbitmq-server
To determine whether the rabbitmq service is running, enter the command:
sudo service rabbitmq-server status
If rabbitmq is not running, enter this command to start it:
sudo service rabbitmq-server start

Configure Adapter Settings

You can place AMQP protocol adapter specific information in a custom configuration named, for example, cfg_amqp.txt. Here is an example of configuration file entries for an AMQP broker installed on the local machine:
[message-broker]
hostname = localhost
username = guest
password = guest
port = 5672
exchange = amq.topic
topic = topicname
The properties in the configuration file are:
hostname: Hostname of the host on which the AMQP broker is installed
username: Username used to log in to the broker
password: Password used to log in to the broker
port: Port used to communicate with the AMQP broker
exchange: Name of the exchange on which to publish messages
topic: Message topic

Using the Adapter

To use the AMQP protocol client adapter in a DeepStream application, set the Gst-nvmsgbroker plugin’s proto-lib property to the pathname of the adapter’s shared library, libnvds_amqp_proto.so.
proto-lib = <path to libnvds_amqp_proto.so>
You can specify the AMQP connection details in the AMQP adapter specific configuration file (e.g., cfg_amqp.txt) as described above. This is the recommended method. The path to the AMQP configuration file is specified by the Gst property config:
config = <path to cfg_amqp.txt>
Alternatively, you can specify the AMQP protocol’s hostname, port number, and username in the Gst plugin’s conn-str property, and specify the password in the configuration file. In the Gst properties:
conn-str = hostname;5672;username
config = <pathname of AMQP configuration file>
In the AMPQ configuration file:
[message-broker]
password = <password>
You can set the Gst-nvmsgbroker plugin’s topic property to specify the message topic.
topic = <topicname>
Alternatively, you can specify a topic in the AMQP configuration file (cfg_amqp.txt). In the Gst properties, set:
config = <path to cfg_amqp.txt>
In the AMQP configuration file:
[message-broker]
Topic = topicname

Programmatic Integration

Once you have configured the connection, you can integrate the AMQP protocol adapter into your application by using the nvds_msgapi interface to call its functions. Note the following points about the functions defined by the interface:
The connection string passed to nvds_msgapi_connect() has the format Hostname;<port>;username.
For both “send” functions, the topic name is specified either by the Gst-nvmsgbroker plugin’s topic property or by the topic parameter in the AMQP configuration file.
The application must call nvds_msgapi_do_work() after each call to nvds_msgapi_send_async(). The frequency of calls to nvds_msgapi_do_work() determines the rate at which messages waiting to be sent are processed.
The AMQP protocol adapter expects the client to manage usage and retirement of the connection handle. The client must ensure that once a handle is disconnected, it is not used for either a “send” call or a call to nvds_msgapi_do_work(). While the library attempts to ensure graceful failure, if the application calls these functions with retired handles, it does not do so in a thread-safe manner.
Note:
As stated at https://github.com/alanxz/rabbitmq-c#threading, you cannot share a socket, an amqp_connection_state_t, or a channel between threads using the librabbitmq library. This library is designed for use by event-driven, single-threaded applications, and does not yet meet the requirements of threaded applications.
To deal with this limitation, your application must open an AMQP connection (and an associated socket) per thread. If it needs to access a single AMQP connection or any of its channels from more than one thread, you must implement an appropriate locking mechanism.
It is generally simpler to have a connection dedicated to each thread.

Monitor Adapter Execution

The AMQP protocol adapter uses the nvds_logger framework to generate log messages which can help you monitor execution. The adapter generates separate logs for the INFO, DEBUG, and ERROR severity levels, as described in nvds_logger: Logging Framework. You can limit the log messages being generated by setting the level at which log messages are filtered in the logging setup script.
Note:
If the severity level is set to DEBUG, nvds_logger logs the entire contents of each message sent by the AMQP protocol adapter.

nv_msgbroker: Message Broker interface

Deepstream5.0 features a new messagebroker library which can be used to make connections with multiple external brokers. This library acts as a wrapper around the message adapter libraries described in the above section and provides its own API’s
Gst-msgbroker plugin has an option to directly call in to the adapter library API’s for connecting with external entity or use the nvmsgbroker library interface to have the ability to connect with multiple external entities at a time.
A screenshot of a cell phone Description automatically generated
The Gst-nvmsgbroker plugin can call the Api’s in the nvmsgbroker library as shown in the diagram above. The Api’s support:
Creating a connection
Sending messages by asynchronous means
Terminating the connection
Fetching the nvmsgbroker library version number
The nvmsgbroker interface is defined in the header file source/includes/nvmsgbroker.h. This header file defines a set of function pointers which provide an interface analogous to an interface in C++.
The following sections describe the methods defined by the nvmsgbroker interface.

nv_msgbroker_connect(): Create a Connection

NvMsgBrokerClientHandle nv_msgbroker_connect(char *broker_conn_str, char *broker_proto_lib, nv_msgbroker_connect_cb_t connect_cb, char *cfg);
The function accepts a connection string and configures a connection. The broker adapter proto lib implementation can choose whether the function makes a connection to accommodate connectionless protocols such as HTTP.
Parameters
broker_conn_str: A connection string with format specific for protocol adapter
broker_proto_lib: Full Path to Message protocol adapter library
connect_cb : A pointer to a callback function for events associated with the connection.
Cfg: Pathname of a configuration file passed to be passed to the protocol adapter
Connect callback
typedef void (*nv_msgbroker_connect_cb_t)(NvMsgBrokerClientHandle h_ptr, NvMsgBrokerErrorType status );
Where the callback’s parameters are:
h_ptr : The connection handle to identify the initiating call.
status: A code that indicates the status of the connection.
Return Value
A connection handle for use in subsequent interface calls if successful, or NULL otherwise.

nv_msgbroker_send_async(): Send an event asynchronously

NvMsgBrokerErrorType nv_msgbroker_send_async (NvMsgBrokerClientHandle h_ptr, NvMsgBrokerClientMsg message, nv_msgbroker_send_cb_t cb, void *user_ctx);
The API sends data to the endpoint of a connection. It accepts a message topic and a message payload.
Send is asynchronous; it accepts a callback function that is called when the “send” operation is completed.
Parameters
h_ptr: connection handle to Message Broker library
message: Message packet which has details of message payload, payload length , topic
cb : callback to be invoked to notify status of send
user_ctx: pointer to pass to callback for context
Message Packet structure
typedef struct {
char *topic;
void *payload;
size_t payload_len;
} NvMsgBrokerClientMsg;
Send callback
typedef void (*nv_msgbroker_send_cb_t)(void *user_ptr, NvMsgBrokerErrorType flag);
Where the callback’s parameters are:
user_ptr: The user pointer (user_ptr) from the call to nv_msgbroker_send_async() that initiated the “send” operation. Enables the callback function to identify the initiating call.
flag: A code that indicates the completion status of the send operation.

nv_msgbroker_subscribe(): Consume data by subscribing to topics

NvMsgBrokerErrorType nv_msgbroker_subscribe(NvMsgBrokerClientHandle h_ptr, char ** topics, int num_topics, nv_msgbroker_subscribe_cb_t cb, void *user_ctx);
This API is used to subscribe to topic(s) and consume messages from the external entity.
The API is asynchronous and must be called with an already created valid connection handle as parameter. The caller must also provide a pointer to the callback function to receive the consumed messages from the connection endpoint and an optional user_ctx pointer for specifying user context
Parameters
h_ptr: A handle for the connection, obtained by a call to nv_msgbroker_connect()
topics: A 2d pointer which points to a char array of topic names
num_topics: num of topics to subscribe
cb: A pointer to a callback function to get notified of the consumed messages on subscribed topic(s)
user_ctx: user ptr to be passed to callback for context
The pointer to a callback function which is specified as a param in subscribe API is of type nv_msgbroker_subscribe_cb_t defined as:
typedef void (*nv_msgbroker_subscribe_cb_t)(NvMsgBrokerErrorType flag, void *msg, int msglen, char *topic, void *user_ptr);
Where the callback’s parameters are:
flag: To specify the error status of message consumed
msg: Consumed message / payload
msg_len: Length of message in bytes
topic: Topic name where the message was received
user_ptr: pointer passed during subscribe() for context

nv_msgbroker_disconnect(): Terminate a Connection

NvMsgBrokerErrorType nv_msgbroker_disconnect(NvMsgBrokerClientHandle h_ptr);
The function terminates the connection, if the underlying protocol requires it, and frees resources associated with h_ptr.
Parameters
h_ptr: A handle for the connection, obtained by a call to nv_msgbroker_connect()

nv_msgbroker_version(): Get Version Number

char *nv_msgbroker_version();
This function returns a string that identifies the nv_msgbroker version supported by this protocol adapter implementation. The string must use the format "<major>.<minor>", where <major> is a major version number and <minor> is a minor version number. A change in the major version number indicates an API change that may cause incompatibility. When the major version number changes, the minor version number is reset to 1.

nvds_logger: Logging Framework

DeepStream provides a logging framework named nvds_logger. The Kafka protocol adapter uses this framework to generate a run time log. nvds_logger is based on syslog, and offers many related features, including:
Choice of priorities (log levels)
Log filtering and redirection
Shared logging across different DeepStream instances running concurrently
Log retirement and management using logrotate
Cross-platform support

Enabling Logging

To enable logging, run the setup_nvds_logger.sh script. Note that this script must be run with sudo. You may have to modify the permissions associated with this script to make it executable.
The script accepts an optional parameter specifying the pathname of log file to be written. By default, the pathname is /tmp/nvds/ds.log.
Once logging is enabled, you can access the generated log messages by reading the log file.
By default, you must have sudo permissions to read the log file. Standard techniques for syslog-based logging configuration can eliminate this requirement.

Filtering Logs

nvds_logger allows logs to be associate with a severity level similar to that which syslog offers. You can filter log messages based on severity level by modifying the setup script. By default, the script enables logging for messages at the INFO level (level 6) and above. You can modify this as outlined in the comments in the script:
# Modify log severity level as required and rerun this script
# 0 Emergency: system is unusable
# 1 Alert: action must be taken immediately
# 2 Critical: critical conditions
# 3 Error: error conditions
# 4 Warning: warning conditions
# 5 Notice: normal but significant condition
# 6 Informational: informational messages
# 7 Debug: debug-level messages
# refer https://tools.ietf.org/html/rfc5424.html for more information
 
echo "if (\$msg contains 'DSLOG') and (\$syslogseverity <= 6) then $nvdslogfilepath" >> 11-nvds.conf

Retiring and Managing Logs

It is recommended that you limit the size of log files by retiring them periodically. logrotate is a popular utility for this purpose. You can use it in cron jobs so that the log files are automatically archived periodically and are discarded after a desired interval.

Generating Logs

You can implement modules that use the logger by including sources/includes/nvds_logger.h in the source code and linking to the libnvds_logger.so library.
Generating logs programmatically involves three steps:
1. Call nvds_log_open() before you write any log messages.
2. Call nvds_log() to write log messages.
3. Call nvds_log_close() upon completion to flush and close the logs.
Note the nvds_logger is a process-based logging mechanism, so the recommended procedure is to call nvds_log_open() from the main application routine rather than the individual plugins. Similarly, call nvds_log_close() from the main application when it shuts down the application before exit.

Gst-nvdsanalytics

This plugin performs analytics on metadata attached by nvinfer (primary detector) and nvtracker. Analytics refer to Region of Interest (ROI) Filtering, Overcrowding Detection, Direction Detection and Line Crossing. The plugin operates in batch mode, it handles the context for each stream independently. ROI based analytics work on primary detector output, but Direction Detection and Line Crossing requires a tracker-id as previous history/state is required to do both the analytics. The configuration for the rules for analytics is achieved using a configuration file.
The gst-nvdsanalytics plugin extracts the metadata from the batched buffer sent by the upstream (nvtracker/nvinfer) element and passes it to the low-level nvdsanalytics library. The low-level library performs analytics based on the configured rules for each feature for each of the streams, the library returns the analytics output, which is for each tracked object as well for the complete frame.
The analytics output (Frame level) is encapsulated in the NvDsAnalyticsFrameMeta structure and is added as user meta with meta_type set to NVDS_USER_FRAME_META_NVDSANALYTICS.The user meta is added to the frame_user_meta_list member of NvDsFrameMeta.
The analytics output (per detected Object) is encapsulated in the NvDsAnalyticsObjInfo structure and is added as user meta with meta_type set to NVDS_USER_OBJ_META_NVDSANALYTICS. The user meta is added to the obj_user_meta_list member of NvDsObjectMeta.
The definition of NvDsAnalyticsObjInfo NvDsAnalyticsFrameMeta is available in sources/includes/nvds_analytics_meta.h header file.
For guidance on how to access user metadata, see User/Custom Metadata Addition Inside NvDsBatchMeta and Tensor Metadata.
 
A screenshot of a cell phone Description automatically generated

Inputs and Outputs

Inputs
GStreamer buffer containing NV12/RGBA frame(s) with attached metadata
Control Parameters
enable: True Enables the plugin, False sets it in pass-through mode
config-file: Configuration file which consist of the analytics rules
Output
Original NV12/RGBA batched buffer
NvDsAnalyticsFrameMeta (meta containing information about individual frames in the batched buffer)
NvDsAnalyticsObjInfo (meta containing information about individual objects in the individual frames of batched buffer)

Features

The following table summarizes the features of the plugin.
Features of the Gst-nvdsanalytics plugin
Feature
Description
Release
ROI Filtering
This feature detects presence of objects in the ROI, the result is attached as metadata for every object, as well as total count of objects in ROI per frame.
DS 5.0
Overcrowding Detection
This feature detects presence of objects in the ROI, the result is attached as metadata for every object, as well as total count of objects in ROI per frame along with overcrowding status, i.e. no of objects in ROI exceed a pre-configured threshold.
DS 5.0
Direction Detection
Checks using history of position of object and the current frame information if it is following a preconfigured direction. The result is attached as metadata for every object.
DS 5.0
Line Crossing
This feature checks if object is following a preconfigured direction for the virtual line and if it has crossed the virtual line. The result is attached to object when Line crossing also frame meta where cumulative count along with per frame count of line crossing is attached.
DS 5.0

Gst Properties

The following table describes the Gst properties of the Gst-nvdsanalytics plugin.
Gst-nvdsanalytics plugin, Gst properties
Property
Meaning
Type and Range
Example Notes
unique-id
Unique identification unsigned integer value for element to identify the output attached by the element
Integer,
0 to 4,294,967,295
unique-id=17
enable
True Enables the plugin, False sets it in pass-through mode
Boolean
enable=1
config-file
Configuration file which consist of the analytics rules
String
config-file=config_nvdsanalytics.txt

Configuration File Parameters

The Gst-nvdsanalytics configuration file uses a “Key File” format described in:
The [property] group configures the general behavior of the plugin. It is the only mandatory group.
The [roi-filtering-stream-<n>] group configures ROI filtering rules parameters for stream specified by <n>. For example, classes. [roi-filtering-stream-0] configures ROI filtering rules for stream ID 0.
The [overcrowding-<n>] group configures Overcrowding parameters for a stream specified by <n>.
The [direction-detection-<n>] group configures Direction Detection parameters for a stream specified by <n>.
The [line-crossing-<n>] group configures Line Crossing parameters for a stream specified by <n>.
The following table respectively describe the keys supported for [property] groups and [<feature>-stream-<n>] groups.
Gst-nvdsanalytics plugin, configuration file, parameters
Property
Applicable Groups
Meaning
Type and Range
Example Notes
enable
[property]
[<feature>-stream-<n>]
Common property to enable or disable the plugin or feature
Boolean
enable=1
config-width
[property]
Width for which the analytics rules are configured
Integer, >0
config-width=1280
config-height
[property]
Height for which the analytics rules are configured
Integer, >0
config-height=720
osd-mode
[property]
0: Disables display of any lines, ROIS and text
1: Display only lines, rois and static text i.e. labels
2: Display all info from 1 in addition, information for all the events
Integer0,1,2
osd-mode=2
 
 
 
 
 
display-font-size
[property]
Set OSD font size for the analytics data
Integer > 0
display-font-size=12
roi-<label>
[roi-filtering-stream-<n>]
[overcrowding-stream-<n>]
The ROI can be specified using roi key followed by its corresponding label (roi-<label>) the value consist of semi-colon delimited coordinates of the polygon (roi-<label>=x1;y1;x2;y2;x3;y3;x4;y4;x5;y5) . The user can specify a simple polygon with > 3 points. The points should be sequentially specified, as the relative position of points is required to check object in polygon.
String
roi-RF= 295;643;579;634;642;913;56;828
roi-OC= 295;643;579;634;642;913;56;828
inverse-roi
[roi-filtering-stream-<n>]
If the flag set true, it indicates the object outside the configured ROI be attached with the ROI label, and count the objects outside the ROI and send as frame level output
Boolean
inverse-roi=0
class-id
[<feature>-stream-<n>]
The class ID separated by semi-colon for which analytic rules should be applied.
-1 indicate that the rules are to be applied to all the classes
String
class-id=0;1;2
or
class-id=-1
object-threshold
[overcrowding-stream-<n>]
The total count after which overcrowding flag should be indicated in the frame metadata.
Integer, >=0
object-threshold=10
direction-<label>
[direction-detection-stream-<n>]
The value indicates the direction (x1;y1;x2;y2)  which corresponds to the configured <label>. When object is moving in configured direction, the label of the particular rule is attached to the object as user metadata
String
direction-South=284;840;360;662
line-crossing-<label>
[line-crossing-stream-<n>]
The value indicates 2 coordinates of direction followed by 2 coordinates of virtual line. These coordinates are delimited using semi-colon (line-crossing-<label>=x1d;y1d;x2d;y2d;x1c;y1c;x2c;y2c). The direction indicates the direction of object in which it should be moving that can be considered for counting, so the object should be in direction x1d,y1d to x2d,y2d, which indicates a direction vector. The line crossing coordinates x1c,y1c and x2c,y2c indicate a virtual line which when an object following a configured direction crosses is then accounted for line crossing. <label> is string identification of the rule. Multiple line-crossings can be defined for a single stream
String
line-crossing-Exit=789;672;1084;900;851;773;1203;732
extended
[line-crossing-stream-<n>]
Boolean parameter to check crossings only on the configured line or for the extended line covering the video frame. If extended is 0, the line crossing only the configured line would be counted
Boolean
extended=0
mode
[line-crossing-stream-<n>]
[direction-detection-stream-<n>]
Parameter to allow user configuration of adherence of object direction with configured direction.
Possible options
strict, balanced, loose. Operate as per name suggestion, where loose will just check if the object has crossed the line and would need the object just to be in same direction with very high tolerance
String
mode=loose
 
mode=strict
 
mode=balanced
 
Note:
The config-width, config-height, indicate the resolution at which analytics rules have been configured. If the runtime stream resolution is different than the configuration resolution. The plugin handles the resolution change and scales the rules for the runtime resolution. The configuration rules are not present in absolute pixel values.
The following pipelines demonstrate plugin’s usage.
For dGPU:
gst-launch-1.0 filesrc location=streams/sample_1080p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! m.sink_0  nvstreammux name=m width=1920 height=1080 batch-size=1 live-source=1 ! nvinfer config-file-path= config_infer_primary.txt ! nvtracker ll-lib-file = /opt/nvidia/deepstream/deepstream/lib/libnvds_nvdcf.so ll-config-file= tracker_config.yml tracker-width=640 tracker-height=384   ! nvdsanalytics config-file= config_nvdsanalytics.txt ! nvmultistreamtiler ! nvvideoconvert ! nvdsosd ! nveglglessink
For Jetson:
gst-launch-1.0 filesrc location=streams/sample_1080p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! m.sink_0 nvstreammux name=m width=1920 height=1080 batch-size=1 live-source=1 ! nvinfer config-file-path= config_infer_primary.txt ! nvtracker ll-lib-file = /opt/nvidia/deepstream/deepstream/lib/libnvds_nvdcf.so ll-config-file= tracker_config.yml tracker-width=640 tracker-height=384 ! nvdsanalytics config-file= config_nvdsanalytics.txt ! nvmultistreamtiler ! nvvideoconvert ! nvdsosd ! nvegltransform ! nveglglessink
The configuration files are located at sources/apps/sample_apps/deepstream-nvdsanalytics-test/config_nvdsanalytics.txt.