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 {
142 
146 typedef enum
147 {
160 
164 typedef enum {
168  NvDsInferUffOrder_kNCHW _DS_DEPRECATED_("Use NvDsInferTensorOrder_kNCHW instead") = NvDsInferTensorOrder_kNCHW,
169  NvDsInferUffOrder_kNHWC _DS_DEPRECATED_("Use NvDsInferTensorOrder_kNCWH instead") = NvDsInferTensorOrder_kNHWC,
170  NvDsInferUffOrder_kNC _DS_DEPRECATED_("Use NvDsInferTensorOrder_kNC instead") = NvDsInferTensorOrder_kNC
172 
173 #define NvDsInferUffOrder _Pragma \
174  ("GCC warning \"'NvDsInferUffOrder' macro is deprecated. Use NvDsInferTensorOrder instead.\"") \
175  NvDsInferTensorOrder
176 
180 typedef struct
181 {
184  union {
185  float threshold _DS_DEPRECATED_("Use preclusterThreshold instead.");
187  };
188 
192 
195  float eps;
198  int minBoxes;
205  float minScore;
209 
213 typedef enum
214 {
225 {
228  unsigned int uniqueID;
229 
232 
243 
247 
248  union {
252  NvDsInferDimsCHW uffDimsCHW _DS_DEPRECATED_("Use inputDims instead.");
253  };
254 
259 
262 
267 
271  unsigned int maxBatchSize;
272 
277 
281 
284 
287 
292  unsigned int numOffsets;
293 
296 
299  _DS_DEPRECATED_("Use NvDsInferClusterMode instead")
301 
303  unsigned int numDetectedClasses;
304 
308 
312 
314 
318  unsigned int numOutputLayers;
319 
328  char customClassifierParseFuncName[_MAX_STR_LENGTH];
329 
333 
335  unsigned int gpuID;
336 
338  int useDLA;
340  int dlaCore;
341 
344  unsigned int outputBufferPoolSize;
345 
350 
352  char customEngineCreateFuncName[_MAX_STR_LENGTH];
353 
358 
362  unsigned int workspaceSize;
363 
366 
370 
378 typedef void (* NvDsInferContextReturnInputAsyncFunc) (void *data);
379 
383 typedef struct
384 {
387  void** inputFrames;
389  unsigned int numInputFrames;
393  unsigned int inputPitch;
400 
404 typedef struct
405 {
407  float left;
409  float top;
411  float width;
413  float height;
417  char *label;
418  /* confidence score of the detected object. */
419  float confidence;
421 
426 typedef struct
427 {
431  unsigned int numObjects;
433 
438 typedef struct
439 {
445  unsigned int numAttributes;
448  char *label;
450 
454 typedef struct
455 {
457  unsigned int width;
459  unsigned int height;
461  unsigned int classes;
464  int *class_map;
470 
474 typedef struct
475 {
482  union
483  {
493  };
495 
500 typedef struct
501 {
505  unsigned int numFrames;
506 
512 
515  void **hostBuffers;
517  unsigned int numHostBuffers;
518 
520  void* priv;
522 
524 typedef struct INvDsInferContext * NvDsInferContextHandle;
525 
543  unsigned int uniqueID, NvDsInferLogLevel logLevel, const char* logMessage,
544  void* userCtx);
545 
546 #ifdef __cplusplus
547 extern "C" {
548 #endif
549 
556 
565 _DS_DEPRECATED_("NvDsInferContext_GetStatusName is deprecated. Use NvDsInferStatus2Str instead")
566 const char * NvDsInferContext_GetStatusName (NvDsInferStatus status);
567 
568 
569 #ifdef __cplusplus
570 }
571 #endif
572 
580 #ifdef __cplusplus
581 
582 #include <string>
583 #include <vector>
584 
588 struct INvDsInferContext
589 {
590 public:
607  virtual NvDsInferStatus queueInputBatch(NvDsInferContextBatchInput &batchInput) = 0;
608 
620  virtual NvDsInferStatus dequeueOutputBatch(NvDsInferContextBatchOutput &batchOutput) = 0;
621 
629  virtual void releaseBatchOutput(NvDsInferContextBatchOutput &batchOutput) = 0;
630 
638  virtual void fillLayersInfo(std::vector<NvDsInferLayerInfo> &layersInfo) = 0;
639 
645  virtual void getNetworkInfo(NvDsInferNetworkInfo &networkInfo) = 0;
646 
655  virtual const std::vector< std::vector<std::string> >& getLabels() = 0;
656 
660  virtual void destroy() = 0;
661 
663  virtual ~INvDsInferContext() {}
664 };
665 
679 NvDsInferStatus createNvDsInferContext(NvDsInferContextHandle *handle,
680  NvDsInferContextInitParams &initParams,
681  void *userCtx = nullptr,
682  NvDsInferContextLoggingFunc logFunc = nullptr);
683 
684 #endif
685 
694 #ifdef __cplusplus
695 extern "C" {
696 #endif
697 
698 
713  NvDsInferContextInitParams *initParams, void *userCtx,
715 
723 
735  NvDsInferContextBatchInput *batchInput);
736 
749  NvDsInferContextBatchOutput *batchOutput);
750 
761  NvDsInferContextBatchOutput *batchOutput);
762 
770  NvDsInferNetworkInfo *networkInfo);
771 
780 
792  NvDsInferLayerInfo *layersInfo);
793 
805  unsigned int id, unsigned int value);
806 
807 #ifdef __cplusplus
808 }
809 #endif
810 
813 #endif
814 
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:160
int copyInputToHostBuffers
Holds a Boolean; true if the input layer contents are to be copied to host memory for access by the a...
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.
unsigned int numDetectedClasses
Holds the number of classes detected by a detector network.
int classIndex
Holds the index for the object's class.
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:205
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.
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.
Copyright (c) 2017-2020, NVIDIA CORPORATION.
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...
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:178
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.
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.
const char * NvDsInferContext_GetStatusName(NvDsInferStatus status)
Gets the string name of the status.
int useDBScan
Holds a Boolean; true if DBScan is to be used for object clustering, or false if OpenCV groupRectangl...
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.
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.
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...
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.