NVIDIA DeepStream SDK API Reference

6.1.1 Release

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvdsinfer_context.h
Go to the documentation of this file.
1 
83 #ifndef __NVDSINFER_CONTEXT_H__
84 #define __NVDSINFER_CONTEXT_H__
85 
86 #include "nvdsinfer.h"
87 
96 #define _PATH_MAX 4096
97 
100 #define _MAX_CHANNELS 4
101 
103 #define _MAX_STR_LENGTH 1024
104 
106 #define NVDSINFER_MAX_BATCH_SIZE 1024
107 
110 #define NVDSINFER_MIN_OUTPUT_BUFFERPOOL_SIZE 2
111 
115 typedef enum
116 {
121 
125 typedef enum
126 {
146 
150 typedef enum
151 {
166 
170 typedef enum {
174  NvDsInferUffOrder_kNCHW _DS_DEPRECATED_("Use NvDsInferTensorOrder_kNCHW instead") = NvDsInferTensorOrder_kNCHW,
175  NvDsInferUffOrder_kNHWC _DS_DEPRECATED_("Use NvDsInferTensorOrder_kNCWH instead") = NvDsInferTensorOrder_kNHWC,
176  NvDsInferUffOrder_kNC _DS_DEPRECATED_("Use NvDsInferTensorOrder_kNC instead") = NvDsInferTensorOrder_kNC
178 
179 #define NvDsInferUffOrder _Pragma \
180  ("GCC warning \"'NvDsInferUffOrder' macro is deprecated. Use NvDsInferTensorOrder instead.\"") \
181  NvDsInferTensorOrder
182 
186 typedef struct
187 {
190  union {
191  float threshold _DS_DEPRECATED_("Use preclusterThreshold instead.");
193  };
194 
198 
201  float eps;
204  int minBoxes;
211  float minScore;
216  int topK;
218 
222 typedef enum
223 {
234 {
237  unsigned int uniqueID;
238 
241 
252 
256 
257  union {
262  } _DS_DEPRECATED_("Use inferInputDims instead.");
263 
268 
271 
274 
279 
283  unsigned int maxBatchSize;
284 
289 
293 
296 
299 
304  unsigned int numOffsets;
305 
308 
311  _DS_DEPRECATED_("Use NvDsInferClusterMode instead")
313 
315  unsigned int numDetectedClasses;
316 
320 
324 
326 
330  unsigned int numOutputLayers;
331 
332 
341  char customClassifierParseFuncName[_MAX_STR_LENGTH];
342 
346 
348  unsigned int gpuID;
349 
351  int useDLA;
353  int dlaCore;
354 
357  unsigned int outputBufferPoolSize;
358 
363 
365  char customEngineCreateFuncName[_MAX_STR_LENGTH];
366 
371 
375  unsigned int workspaceSize;
376 
379 
382 
385  char customBBoxInstanceMaskParseFuncName[_MAX_STR_LENGTH];
386 
392  unsigned int numOutputIOFormats;
393 
400 
403 
410 
418 typedef void (* NvDsInferContextReturnInputAsyncFunc) (void *data);
419 
423 typedef struct
424 {
427  void** inputFrames;
429  unsigned int numInputFrames;
433  unsigned int inputPitch;
440 
441 typedef struct
442 {
445  unsigned int numInputTensors;
452 
456 typedef struct
457 {
459  float left;
461  float top;
463  float width;
465  float height;
469  char *label;
470  /* confidence score of the detected object. */
471  float confidence;
472  /* Instance mask information for the object. */
473  float *mask;
475  unsigned int mask_width;
477  unsigned int mask_height;
479  unsigned int mask_size;
481 
486 typedef struct
487 {
491  unsigned int numObjects;
493 
498 typedef struct
499 {
505  unsigned int numAttributes;
508  char *label;
510 
514 typedef struct
515 {
517  unsigned int width;
519  unsigned int height;
521  unsigned int classes;
524  int *class_map;
530 
534 typedef struct
535 {
542  union
543  {
553  };
555 
560 typedef struct
561 {
565  unsigned int numFrames;
566 
572 
575  void **hostBuffers;
577  unsigned int numHostBuffers;
578 
580  void* priv;
582 
584 typedef struct INvDsInferContext * NvDsInferContextHandle;
585 
603  unsigned int uniqueID, NvDsInferLogLevel logLevel, const char* logMessage,
604  void* userCtx);
605 
606 #ifdef __cplusplus
607 extern "C" {
608 #endif
609 
616 
625 _DS_DEPRECATED_("NvDsInferContext_GetStatusName is deprecated. Use NvDsInferStatus2Str instead")
626 const char * NvDsInferContext_GetStatusName (NvDsInferStatus status);
627 
628 
629 #ifdef __cplusplus
630 }
631 #endif
632 
640 #ifdef __cplusplus
641 
642 #include <string>
643 #include <vector>
644 
648 struct INvDsInferContext
649 {
650 public:
667  virtual NvDsInferStatus queueInputBatch(NvDsInferContextBatchInput &batchInput) = 0;
668 
680  virtual NvDsInferStatus dequeueOutputBatch(NvDsInferContextBatchOutput &batchOutput) = 0;
681 
689  virtual void releaseBatchOutput(NvDsInferContextBatchOutput &batchOutput) = 0;
690 
698  virtual void fillLayersInfo(std::vector<NvDsInferLayerInfo> &layersInfo) = 0;
699 
705  virtual void getNetworkInfo(NvDsInferNetworkInfo &networkInfo) = 0;
706 
715  virtual const std::vector< std::vector<std::string> >& getLabels() = 0;
716 
720  virtual void destroy() = 0;
721 
723  virtual ~INvDsInferContext() {}
724 
734  virtual NvDsInferStatus queueInputBatchPreprocessed(NvDsInferContextBatchPreprocessedInput &batchInput) = 0;
735 };
736 
750 NvDsInferStatus createNvDsInferContext(NvDsInferContextHandle *handle,
751  NvDsInferContextInitParams &initParams,
752  void *userCtx = nullptr,
753  NvDsInferContextLoggingFunc logFunc = nullptr);
754 
755 #endif
756 
765 #ifdef __cplusplus
766 extern "C" {
767 #endif
768 
769 
784  NvDsInferContextInitParams *initParams, void *userCtx,
786 
794 
806  NvDsInferContextBatchInput *batchInput);
807 
820  NvDsInferContextBatchOutput *batchOutput);
821 
832  NvDsInferContextBatchOutput *batchOutput);
833 
841  NvDsInferNetworkInfo *networkInfo);
842 
851 
863  NvDsInferLayerInfo *layersInfo);
864 
876  unsigned int id, unsigned int value);
877 
878 #ifdef __cplusplus
879 }
880 #endif
881 
884 #endif
885 
float height
Holds the object's height.
unsigned int maxBatchSize
Holds the maximum number of frames to be inferred together in a batch.
NvDsInferTensorOrder
Defines UFF input layer orders.
NvDsInferNetworkMode
Defines internal data formats used by the inference engine.
NvDsInferStatus NvDsInferContext_QueueInputBatch(NvDsInferContextHandle handle, NvDsInferContextBatchInput *batchInput)
Queues a batch of input frames for preprocessing and inferencing.
void NvDsInferContext_GetNetworkInfo(NvDsInferContextHandle handle, NvDsInferNetworkInfo *networkInfo)
Gets network input information.
Holds detection and bounding box grouping parameters.
NvDsInferStatus NvDsInferContext_Create(NvDsInferContextHandle *handle, NvDsInferContextInitParams *initParams, void *userCtx, NvDsInferContextLoggingFunc logFunc)
Creates a new NvDsInferContext object with specified initialization parameters.
char modelEngineFilePath[_PATH_MAX]
Holds the pathname of the serialized model engine file.
int inputFromPreprocessedTensor
Boolean flag indicating that caller will supply preprocessed tensors for inferencing.
void NvDsInferContext_Destroy(NvDsInferContextHandle handle)
Destroys an NvDsInferContext instance and releases its resources.
NvDsInferNetworkMode networkMode
Holds an internal data format specifier used by the inference engine.
unsigned int numInputTensors
Holds the number of input tensors.
char uffInputBlobName[_MAX_STR_LENGTH]
Holds the name of the input layer for the UFF model.
Holds the initialization parameters required for the NvDsInferContext interface.
NvDsInferTensorOrder netInputOrder
Holds the original input order for the network.
unsigned int gpuID
Holds the ID of the GPU which is to run the inference.
NvDsInferTensorOrder uffInputOrder
Holds the original input order for the UFF model.
NvDsInferClusterMode clusterMode
Holds the type of clustering mode.
Holds information about one classified attribute.
Definition: nvdsinfer.h:198
int copyInputToHostBuffers
Holds a Boolean; true if the input layer contents are to be copied to host memory for access by the a...
NvDsInferDimsCHW uffDimsCHW
Holds the input dimensions for the UFF model.
unsigned int mask_size
Holds size of mask in bytes.
NvDsInferFormat
Defines color formats.
void NvDsInferContext_ReleaseBatchOutput(NvDsInferContextHandle handle, NvDsInferContextBatchOutput *batchOutput)
Frees the memory associated with the batch output and releases the set of host buffers back to the co...
#define _PATH_MAX
Maximum length of a file path parameter.
NvDsInferContext_GetStatusName is deprecated Use NvDsInferStatus2Str instead const char * NvDsInferContext_GetStatusName(NvDsInferStatus status)
Gets the string name of the status.
unsigned int mask_height
Holds height of mask.
unsigned int numDetectedClasses
Holds the number of classes detected by a detector network.
int classIndex
Holds the index for the object's class.
unsigned int mask_width
Holds width of mask.
void ** inputFrames
Holds a pointer to an array of pointers to input frame buffers.
char customEngineCreateFuncName[_MAX_STR_LENGTH]
Name of the custom engine creation function in the custom library.
unsigned int numInputFrames
Holds the number of input frames, i.e.
Holds the output for all of the frames in a batch (an array of frame), and related buffer information...
NvDsInferDetectionParams * perClassDetectionParams
Holds per-class detection parameters.
char meanImageFilePath[_PATH_MAX]
Holds the pathname of the mean image file (PPM format).
char * label
Holds a pointer to a string containing a label for the object.
void NvDsInferContext_FillLayersInfo(NvDsInferContextHandle handle, NvDsInferLayerInfo *layersInfo)
Fills an input vector with information about all of the bound layers of the inference engine in an Nv...
unsigned int numOutputDeviceBuffers
Holds the number of elements in *outputDeviceBuffers.
unsigned int uniqueID
Holds a unique identifier for the instance.
int dlaCore
Holds the ID of the DLA core to use.
unsigned int outputBufferPoolSize
Holds the number of sets of output buffers (host and device) to be allocated.
float left
Holds the object's offset from the left boundary of the frame.
char protoFilePath[_PATH_MAX]
Holds the pathname of the prototxt file.
float width
Holds the object's width.
NvDsInferNetworkType outputType
Holds an output type indicating the valid member in the union of detectionOutput, classificationOutpu...
Specifies 8-bit Luma format.
unsigned int numOutputLayers
Holds the number of output layer names.
NvDsInferLogLevel
Enum for the log levels of NvDsInferContext.
Definition: nvdsinfer.h:246
NvDsInferNetworkType networkType
Holds the network type.
unsigned int numHostBuffers
Holds the number of elements in hostBuffers.
NvDsInferContextReturnInputAsyncFunc returnInputFunc
Holds a callback for returning the input buffers to the client.
float * class_probability_map
Holds a pointer to an array containing raw probabilities.
char ** layerDevicePrecisions
Can be used to specify the device type and inference precision of layers.
float classifierThreshold
Holds the minimum confidence threshold for the classifier to consider a label valid.
void * priv
Holds a private context pointer for the set of output buffers.
char int8CalibrationFilePath[_PATH_MAX]
Holds the pathname of the INT8 calibration file.
float offsets[_MAX_CHANNELS]
Holds the per-channel offsets for mean subtraction.
NVIDIA DeepStream inference specifications
Use NvDsInferClusterMode instead int useDBScan
Holds a Boolean; true if DBScan is to be used for object clustering, or false if OpenCV groupRectangl...
char tltEncodedModelFilePath[_PATH_MAX]
Holds the pathname of the TLT encoded model file.
#define _MAX_STR_LENGTH
Defines the maximum length of string parameters.
Holds information about one batch to be inferred.
void(* NvDsInferContextReturnInputAsyncFunc)(void *data)
Defines a callback function type for asynchronously returning the input client buffers to the NvDsInf...
unsigned int numLayerDevicePrecisions
Holds number of layer device precisions specified.
char ** outputLayerNames
Holds a pointer to an array of pointers to output layer names.
void(* NvDsInferContextLoggingFunc)(NvDsInferContextHandle handle, unsigned int uniqueID, NvDsInferLogLevel logLevel, const char *logMessage, void *userCtx)
Type declaration for a logging callback.
Holds information about one detected object.
NvDsInferClassificationOutput classificationOutput
Holds classifier output.
char onnxFilePath[_PATH_MAX]
Holds the pathname of the ONNX model file.
Holds information on all attributes classifed by a classifier network for one frame.
Specifies 24-bit interleaved R-G-B format.
unsigned int numAttributes
Holds the size of the attributes array.
float postClusterThreshold
Hold the bounding box detection threshold to be applied post clustering operation.
NvDsInferDetectionOutput detectionOutput
Holds detector output.
NvDsInferFormat networkInputFormat
Holds the network input format.
NvDsInferAttribute * attributes
Holds a pointer to an array of attributes.
Holds information parsed from segmentation network output for one frame.
struct INvDsInferContext * NvDsInferContextHandle
An opaque pointer type to be used as a handle for a context instance.
char customNetworkConfigFilePath[_PATH_MAX]
Holds the pathname of the configuration file for custom network creation.
const char * NvDsInferContext_GetLabel(NvDsInferContextHandle handle, unsigned int id, unsigned int value)
Gets the string label associated with the class ID for detectors and the attribute ID and attribute v...
unsigned int height
Holds the height of the output.
char customBBoxParseFuncName[_MAX_STR_LENGTH]
Holds the name of the custom bounding box function in the custom library.
Holds information on all objects detected by a detector network in one frame.
void NvDsInferContext_ResetInitParams(NvDsInferContextInitParams *initParams)
Resets a context parameter structure to default values.
#define _MAX_CHANNELS
Defines the maximum number of channels supported by the API for image input layers.
Specifies a segmentation network.
unsigned int NvDsInferContext_GetNumLayersInfo(NvDsInferContextHandle handle)
Gets the number of the bound layers of the inference engine in an NvDsInferContext instance...
Specifies 32-bit interleaved R-G-B-A format.
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
Definition: nvdsinfer.h:217
unsigned int numOutputIOFormats
Holds number of output IO formats specified.
char tltModelKey[_MAX_STR_LENGTH]
Holds the string key for decoding the TLT encoded model.
NvDsInferTensorOrder segmentationOutputOrder
Holds output order for segmentation network.
unsigned int numObjects
Holds the number of objects in objects.
char labelsFilePath[_PATH_MAX]
Holds the pathname of the labels file containing strings for the class labels.
unsigned int classes
Holds the number of classes supported by the network.
void * returnFuncData
A pointer to the data to be supplied with the callback in returnInputFunc.
NvDsInferNetworkType
Defines network types.
NvDsInferDimsCHW inferInputDims
Inference input dimensions for runtime engine.
int forceImplicitBatchDimension
For model parsers supporting both implicit batch dim and full dims, prefer to use implicit batch dim...
char uffFilePath[_PATH_MAX]
Holds the pathname of the UFF model file.
unsigned int inputPitch
Holds the pitch of the input frames, in bytes.
unsigned int width
Holds the width of the output.
char modelFilePath[_PATH_MAX]
Holds the pathname of the caffemodel file.
NvDsInferObject * objects
Holds a pointer to an array of objects.
Holds the information inferred by the network on one frame.
int topK
Number of objects with objects to be filtered in the decensding order of probability.
float nmsIOUThreshold
IOU threshold to be used with NMS mode of clustering.
Holds information about the model network.
Definition: nvdsinfer.h:109
void ** hostBuffers
Holds a pointer to an array of pointers to host buffers for this batch.
float eps
Holds the epsilon to control merging of overlapping boxes.
NvDsInferSegmentationOutput segmentationOutput
Holds classifier output.
Holds the dimensions of a three-dimensional layer.
Definition: nvdsinfer.h:58
char customLibPath[_PATH_MAX]
Holds the pathname of the library containing custom methods required to support the network...
NvDsInferDimsCHW inputDims
Holds the input dimensions for the model.
int useDLA
Holds a Boolean; true if DLA is to be used.
NvDsInferFrameOutput * frames
Holds a pointer to an array of outputs for each frame in the batch.
Holds information about one layer in the model.
Definition: nvdsinfer.h:86
char * label
Holds a pointer to a string containing a label for the classified output.
Specifies 24-bit interleaved B-G-R format.
int groupThreshold
Holds the minimum number boxes in a cluster to be considered an object during grouping using OpenCV g...
NvDsInferClusterMode
Enum for clustering mode for detectors.
int * class_map
Holds a pointer to an array for the 2D pixel class map.
unsigned int numFrames
Holds the number of elements in frames.
char customBBoxInstanceMaskParseFuncName[_MAX_STR_LENGTH]
Holds the name of the bounding box and instance mask parse function in the custom library...
Specifies a classifier.
NvDsInferFormat inputFormat
Holds the format of the frame contents.
unsigned int workspaceSize
Max workspace size (unit MB) that will be used as tensorrt build settings for cuda engine...
float networkScaleFactor
Holds the normalization factor with which to scale the input pixels.
float minScore
Minimum score in a cluster for the cluster to be considered an object during grouping.
Specifies 32-bit interleaved B-G-R-x format.
float top
Holds the object's offset from the top boundary of the frame.
Specifies a instance segmentation network.
NvDsInferStatus NvDsInferContext_DequeueOutputBatch(NvDsInferContextHandle handle, NvDsInferContextBatchOutput *batchOutput)
Dequeues output for a batch of frames.
void * returnFuncData
A pointer to the data to be supplied with the callback in returnInputFunc.
int minBoxes
Holds the minimum number of boxes in a cluster to be considered an object during grouping using DBSCA...
#define _DS_DEPRECATED_(STR)
Definition: nvdsinfer.h:40
char ** outputIOFormats
Can be used to specify the format and datatype for bound output layers.
void ** outputDeviceBuffers
Holds a pointer to an array of pointers to output device buffers for this batch.
NvDsInferContextReturnInputAsyncFunc returnInputFunc
Holds a callback for returning the input buffers to the client.
char customClassifierParseFuncName[_MAX_STR_LENGTH]
Name of the custom classifier attribute parsing function in the custom library.