Skip to navigation

Gst-nvdsvisionencoder-c

View as Markdown

The Gst-nvdsvisionencoder-c plugin is a pure C/C++ GStreamer plugin that generates ReID (Re-Identification) embeddings for tracked objects using either Triton Inference Server or a local TensorRT engine, and attaches them to DeepStream metadata as NVDS_TRACKER_OBJ_REID_META. Compared to an equivalent Python plugin, it attaches metadata directly via C pointers (avoiding wrapper/binding issues), runs without Python overhead, and produces metadata that is correctly visible to all downstream components (for example deepstream-test5-app, Gst-nvmsgconv). It also supports embedding caching with optical-flow-based staleness prediction and an optional DLA-based appearance-change validator, both of which can skip full re-inference for objects whose appearance has not meaningfully changed.

Inputs and Outputs

  • Inputs

    • GStreamer buffer containing NvBufSurface (NVMM) frames with tracked-object metadata
  • Control parameters

    • enable, backend, triton-url, triton-model, tensorrt-engine, onnx-model, batch-size, min-crop-size, gpu-id, device, skip-interval, embedding-classes, verbose
    • smart-infer, cache-refresh-interval, cache-max-size (embedding cache)
    • ofa-predict, ofa-motion-threshold, ofa-high-motion-threshold (optical-flow-based staleness prediction)
    • dla-validator, dla-validator-engine, dla-core, dla-change-threshold (DLA appearance-change validator)
  • Output

    • The same GStreamer buffer, with NVDS_TRACKER_OBJ_REID_META (ReID embeddings) attached to each tracked object’s metadata

Features

The following table summarizes the features of the plugin.

Gst-nvdsvisionencoder-c plugin features

FeatureDescriptionRelease
ReID embedding generationGenerates ReID embeddings for tracked objects via Triton Inference Server or a local TensorRT engineDS 9.2
NVDS_TRACKER_OBJ_REID_META attachmentAttaches generated embeddings directly to DeepStream tracked-object metadata using native C pointersDS 9.2
Minimum crop-size filteringSkips embedding generation for objects smaller than min-crop-sizeDS 9.2
Embedding cachingCaches per-object embeddings (smart-infer) and periodically re-infers them (cache-refresh-interval), avoiding redundant inference for already-embedded tracked objectsDS 9.2
Optical-flow staleness predictionUses hardware optical flow motion vectors (ofa-predict) to transform cached embeddings instead of re-inferring when object motion is below a configurable thresholdDS 9.2
DLA appearance-change validatorGates full vision-encoder inference behind a lightweight DLA (or GPU fallback) appearance-change detectorDS 9.2

Gst Properties

The following table describes the Gst properties of the Gst-nvdsvisionencoder-c plugin.

Gst-nvdsvisionencoder-c plugin gst properties

PropertyMeaningType and RangeExample Notes
enableEnables vision encodingBooleanenable=1
backendInference backend to use (triton or tensorrt)Stringbackend=triton
triton-urlTriton Inference Server URLStringtriton-url=localhost:8001
triton-modelTriton model nameStringtriton-model=radio_clip_trt
model-variantModel variant (for compatibility)Stringmodel-variant=default
tensorrt-enginePath to a TensorRT engine (.plan) file; settable while PLAYING to reload a prebuilt engine on the fly, but the new engine must match the live one’s input resolution, embedding dimension, and batch capacityStringtensorrt-engine=/path/to/model.plan
onnx-modelPath to an ONNX model file used to build the engine if it is not found; cold-start configuration only (setting it on a running element stores it for the next start rather than loading it — use tensorrt-engine for a runtime update)Stringonnx-model=/path/to/model.onnx
batch-sizeTensorRT batch size for engine building/inferenceInteger,
1 to 4,294,967,295
batch-size=16
min-crop-sizeMinimum crop size (width or height) below which an object is skippedInteger,
8 to 512
min-crop-size=32
verboseEnables verbose loggingBooleanverbose=0
gpu-idGPU device IDInteger,
0 to 7
gpu-id=0
deviceDevice type used for inference (cuda or cpu)Stringdevice=cuda
skip-intervalFrame skip interval (0 = none, 1 = every other frame, 2 = every 3rd frame, etc.)Integer,
0 to 100
skip-interval=0
embedding-classesSemicolon-separated list of classes to generate embeddings for; empty means all classesStringembedding-classes=Person;Vehicle
query-onlyInitializes the model for REST API query handling only and skips per-frame pipeline inferenceBooleanquery-only=0
smart-inferSkips inference for tracked objects whose embedding is already cachedBooleansmart-infer=0
cache-refresh-intervalRe-infers cached objects every N frames; 0 means never re-infer while trackedInteger,
0 to 10,000
cache-refresh-interval=0
cache-max-sizeMaximum number of object embeddings to cache; oldest entries are evicted firstInteger,
10 to 100,000
cache-max-size=10000
ofa-predictUses hardware optical flow motion vectors to predict embedding staleness and transform cached embeddings instead of re-inferringBooleanofa-predict=0
ofa-motion-thresholdPer-object average motion magnitude, in flow-vector units (~pixels/frame), below which the cached embedding is trustedFloat,
0.0 to 100.0
ofa-motion-threshold=5.0
ofa-high-motion-thresholdPer-object motion magnitude above which full re-inference is forced because the object’s appearance likely changed significantlyFloat,
0.0 to 500.0
ofa-high-motion-threshold=20.0
dla-validatorEnables a lightweight appearance-change detector on DLA (Jetson) or GPU fallback to gate full vision-encoder inferenceBooleandla-validator=0
dla-validator-enginePath to the TensorRT engine for the lightweight appearance-change detectorStringdla-validator-engine=/path/to/validator.plan
dla-coreDLA core to use for the validator; -1 uses GPU fallbackInteger,
-1 to 7
dla-core=-1
dla-change-thresholdProbability threshold above which the validator considers the object’s appearance changedFloat,
0.0 to 1.0
dla-change-threshold=0.5