NVIDIA DeepStream SDK API Reference

5.0 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 
276 
280  unsigned int maxBatchSize;
281 
286 
290 
293 
296 
301  unsigned int numOffsets;
302 
305 
308  _DS_DEPRECATED_("Use NvDsInferClusterMode instead")
310 
312  unsigned int numDetectedClasses;
313 
317 
321 
323 
327  unsigned int numOutputLayers;
328 
329 
338  char customClassifierParseFuncName[_MAX_STR_LENGTH];
339 
343 
345  unsigned int gpuID;
346 
348  int useDLA;
350  int dlaCore;
351 
354  unsigned int outputBufferPoolSize;
355 
360 
362  char customEngineCreateFuncName[_MAX_STR_LENGTH];
363 
368 
372  unsigned int workspaceSize;
373 
376 
379 
382  char customBBoxInstanceMaskParseFuncName[_MAX_STR_LENGTH];
383 
389  unsigned int numOutputIOFormats;
390 
397 
399 
407 typedef void (* NvDsInferContextReturnInputAsyncFunc) (void *data);
408 
412 typedef struct
413 {
416  void** inputFrames;
418  unsigned int numInputFrames;
422  unsigned int inputPitch;
429 
433 typedef struct
434 {
436  float left;
438  float top;
440  float width;
442  float height;
446  char *label;
447  /* confidence score of the detected object. */
448  float confidence;
449  /* Instance mask information for the object. */
450  float *mask;
452  unsigned int mask_width;
454  unsigned int mask_height;
456  unsigned int mask_size;
458 
463 typedef struct
464 {
468  unsigned int numObjects;
470 
475 typedef struct
476 {
482  unsigned int numAttributes;
485  char *label;
487 
491 typedef struct
492 {
494  unsigned int width;
496  unsigned int height;
498  unsigned int classes;
501  int *class_map;
507 
511 typedef struct
512 {
519  union
520  {
530  };
532 
537 typedef struct
538 {
542  unsigned int numFrames;
543 
549 
552  void **hostBuffers;
554  unsigned int numHostBuffers;
555 
557  void* priv;
559 
561 typedef struct INvDsInferContext * NvDsInferContextHandle;
562 
580  unsigned int uniqueID, NvDsInferLogLevel logLevel, const char* logMessage,
581  void* userCtx);
582 
583 #ifdef __cplusplus
584 extern "C" {
585 #endif
586 
593 
602 _DS_DEPRECATED_("NvDsInferContext_GetStatusName is deprecated. Use NvDsInferStatus2Str instead")
603 const char * NvDsInferContext_GetStatusName (NvDsInferStatus status);
604 
605 
606 #ifdef __cplusplus
607 }
608 #endif
609 
617 #ifdef __cplusplus
618 
619 #include <string>
620 #include <vector>
621 
625 struct INvDsInferContext
626 {
627 public:
644  virtual NvDsInferStatus queueInputBatch(NvDsInferContextBatchInput &batchInput) = 0;
645 
657  virtual NvDsInferStatus dequeueOutputBatch(NvDsInferContextBatchOutput &batchOutput) = 0;
658 
666  virtual void releaseBatchOutput(NvDsInferContextBatchOutput &batchOutput) = 0;
667 
675  virtual void fillLayersInfo(std::vector<NvDsInferLayerInfo> &layersInfo) = 0;
676 
682  virtual void getNetworkInfo(NvDsInferNetworkInfo &networkInfo) = 0;
683 
692  virtual const std::vector< std::vector<std::string> >& getLabels() = 0;
693 
697  virtual void destroy() = 0;
698 
700  virtual ~INvDsInferContext() {}
701 };
702 
716 NvDsInferStatus createNvDsInferContext(NvDsInferContextHandle *handle,
717  NvDsInferContextInitParams &initParams,
718  void *userCtx = nullptr,
719  NvDsInferContextLoggingFunc logFunc = nullptr);
720 
721 #endif
722 
731 #ifdef __cplusplus
732 extern "C" {
733 #endif
734 
735 
750  NvDsInferContextInitParams *initParams, void *userCtx,
752 
760 
772  NvDsInferContextBatchInput *batchInput);
773 
786  NvDsInferContextBatchOutput *batchOutput);
787 
798  NvDsInferContextBatchOutput *batchOutput);
799 
807  NvDsInferNetworkInfo *networkInfo);
808 
817 
829  NvDsInferLayerInfo *layersInfo);
830 
842  unsigned int id, unsigned int value);
843 
844 #ifdef __cplusplus
845 }
846 #endif
847 
850 #endif
851 
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.
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.
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.
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:191
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:236
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:209
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.
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.
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.
char customClassifierParseFuncName[_MAX_STR_LENGTH]
Name of the custom classifier attribute parsing function in the custom library.