NVIDIA DeepStream SDK API Reference

4.0 Release

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
nvdsinfer_context.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA Corporation and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA Corporation is strictly prohibited.
9  *
10  */
11 
80 #ifndef __NVDSINFER_CONTEXT_H__
81 #define __NVDSINFER_CONTEXT_H__
82 
83 #include "nvdsinfer.h"
84 
93 #define _PATH_MAX 4096
94 
96 #define _MAX_CHANNELS 4
97 
99 #define _MAX_STR_LENGTH 1024
100 
102 #define NVDSINFER_MAX_BATCH_SIZE 1024
103 
105 #define NVDSINFER_MIN_OUTPUT_BUFFERPOOL_SIZE 2
106 
110 typedef enum
111 {
116 
120 typedef enum
121 {
135 
139 typedef enum
140 {
153 
157 typedef enum
158 {
163 
167 typedef struct
168 {
170  float threshold;
173  float eps;
176  int minBoxes;
181 
182 
186 typedef enum
187 {
206 
210 typedef enum
211 {
217 
222 {
225  unsigned int uniqueID;
226 
229 
240 
243 
250 
253 
258 
262  unsigned int maxBatchSize;
263 
269 
274 
277 
280 
286  unsigned int numOffsets;
287 
290 
294 
296  unsigned int numDetectedClasses;
297 
301 
304 
306 
309  unsigned int numOutputLayers;
310 
319 
323 
325  unsigned int gpuID;
326 
328  int useDLA;
330  int dlaCore;
331 
333  unsigned int outputBufferPoolSize;
334 
339 
347 typedef void (* NvDsInferContextReturnInputAsyncFunc) (void *data);
348 
352 typedef struct
353 {
356  void** inputFrames;
358  unsigned int numInputFrames;
362  unsigned int inputPitch;
369 
373 typedef struct
374 {
376  unsigned int left;
378  unsigned int top;
380  unsigned int width;
382  unsigned int height;
383  /* Index for the object class. */
385  /* String label for the detected object. */
386  char *label;
388 
393 typedef struct
394 {
398  unsigned int numObjects;
400 
405 typedef struct
406 {
411  unsigned int numAttributes;
413  char *label;
415 
420 typedef struct
421 {
423  unsigned int width;
425  unsigned int height;
427  unsigned int classes;
430  int *class_map;
435 
439 typedef struct
440 {
446  union
447  {
454  };
456 
461 typedef struct
462 {
465  unsigned int numFrames;
466 
470 
472  void **hostBuffers;
473  unsigned int numHostBuffers;
474 
476  unsigned int outputBatchID;
478 
480 typedef struct INvDsInferContext * NvDsInferContextHandle;
481 
495  unsigned int uniqueID, NvDsInferLogLevel logLevel, const char *funcName,
496  const char * logMessage, void *userCtx);
497 
498 
499 #ifdef __cplusplus
500 extern "C" {
501 #endif
502 
508 
516 const char * NvDsInferContext_GetStatusName (NvDsInferStatus status);
517 
518 
519 #ifdef __cplusplus
520 }
521 #endif
522 
530 #ifdef __cplusplus
531 
532 #include <string>
533 #include <vector>
534 
538 struct INvDsInferContext
539 {
540 public:
556  virtual NvDsInferStatus queueInputBatch(NvDsInferContextBatchInput &batchInput) = 0;
557 
568  virtual NvDsInferStatus dequeueOutputBatch(NvDsInferContextBatchOutput &batchOutput) = 0;
569 
577  virtual void releaseBatchOutput(NvDsInferContextBatchOutput &batchOutput) = 0;
578 
586  virtual void fillLayersInfo(std::vector<NvDsInferLayerInfo> &layersInfo) = 0;
587 
593  virtual void getNetworkInfo(NvDsInferNetworkInfo &networkInfo) = 0;
594 
603  virtual const std::vector< std::vector<std::string> >& getLabels() = 0;
604 
608  virtual void destroy() = 0;
609 protected:
610  virtual ~INvDsInferContext() {}
611 };
612 
624 NvDsInferStatus createNvDsInferContext(NvDsInferContextHandle *handle,
625  NvDsInferContextInitParams &initParams,
626  void *userCtx = nullptr,
627  NvDsInferContextLoggingFunc logFunc = nullptr);
628 
629 #endif
630 
639 #ifdef __cplusplus
640 extern "C" {
641 #endif
642 
643 
655  NvDsInferContextInitParams *initParams, void *userCtx,
657 
663 
675  NvDsInferContextBatchInput *batchInput);
676 
688  NvDsInferContextBatchOutput *batchOutput);
689 
699  NvDsInferContextBatchOutput *batchOutput);
700 
708  NvDsInferNetworkInfo *networkInfo);
709 
718 
729  NvDsInferLayerInfo *layersInfo);
730 
742  unsigned int id, unsigned int value);
743 
744 #ifdef __cplusplus
745 }
746 #endif
747 
748 #endif
749 
NvDsInferUffInputOrder
Enum for the UFF input layer order.
unsigned int maxBatchSize
Max number of frames that will be inferred together in a batch.
NvDsInferNetworkMode
Enum for internal data format to be used by the inference engine.
NvDsInferStatus NvDsInferContext_QueueInputBatch(NvDsInferContextHandle handle, NvDsInferContextBatchInput *batchInput)
Queue a batch of input frames for pre-processing and inferencing.
void NvDsInferContext_GetNetworkInfo(NvDsInferContextHandle handle, NvDsInferNetworkInfo *networkInfo)
Get the network input information.
Holds the detection and bounding box grouping parameters.
NvDsInferStatus NvDsInferContext_Create(NvDsInferContextHandle *handle, NvDsInferContextInitParams *initParams, void *userCtx, NvDsInferContextLoggingFunc logFunc)
Creates a new instance of the NvDsInferContext class with the supplied initialization parameters...
char modelEngineFilePath[_PATH_MAX]
Path to the serialized model engine file.
NvDsInferLogLevel
Enum for the log levels of NvDsInferContext.
NvDsInferContext operation succeeded.
void NvDsInferContext_Destroy(NvDsInferContextHandle handle)
Destroy a NvDsInferContext instance and release the associated resources.
NvDsInferNetworkMode networkMode
Internal data format to be used by the inference engine.
char uffInputBlobName[_MAX_STR_LENGTH]
Name of the input layer for the UFF model.
Holds the initialization parameters required for the NvDsInferContext interface.
unsigned int gpuID
ID of the GPU to run the inference on.
TensorRT interface failed.
Invalid parameters were supplied.
Holds information about one classified attribute.
Definition: nvdsinfer.h:152
int copyInputToHostBuffers
Boolean indicating if input layer contents should be copied to host memories for access in the applic...
NvDsInferDimsCHW uffDimsCHW
Input dimensions for the UFF model.
NvDsInferFormat
Enum for color formats.
void NvDsInferContext_ReleaseBatchOutput(NvDsInferContextHandle handle, NvDsInferContextBatchOutput *batchOutput)
Free the memory associated with the batch output and release the set of host buffers back to the cont...
#define _PATH_MAX
Maximum length of a file path parameter.
unsigned int numDetectedClasses
Number of classes detected by a detector network.
unsigned int width
Object width.
void ** inputFrames
Array of pointers to buffers for input frames.
unsigned int numInputFrames
Number of input frames i.e.
A batch is an array of frames.
NvDsInferDetectionParams * perClassDetectionParams
Per class detection parameters.
char meanImageFilePath[_PATH_MAX]
Path to the mean image file (PPM format).
void NvDsInferContext_FillLayersInfo(NvDsInferContextHandle handle, NvDsInferLayerInfo *layersInfo)
Fill the input vector with information on all the bound layers of the inference engine in the NvDsInf...
unsigned int uniqueID
Unique identifier for the instance.
int dlaCore
DLA Core to use.
unsigned int outputBufferPoolSize
Number of sets of output buffers (host and device) to be allocated.
CUDA error was encountered.
char protoFilePath[_PATH_MAX]
Path to the prototxt file.
NvDsInferNetworkType outputType
Output type indicating the valid member in the union.
NvDsInferNetworkType networkType
Type of the network.
NvDsInferContextReturnInputAsyncFunc returnInputFunc
Callback function for returning the input buffers back to the client.
float * class_probability_map
Pointer to the raw array containing the probabilities.
float classifierThreshold
Minimum confidence threshold for classifier to consider a label valid.
char int8CalibrationFilePath[_PATH_MAX]
Path to the INT8 calibration file.
float offsets[_MAX_CHANNELS]
Per channel offsets for mean subtraction.
NVIDIA DeepStream inference specifications
char tltEncodedModelFilePath[_PATH_MAX]
Path to the TLT encoded model file.
#define _MAX_STR_LENGTH
Maximum length of string parameters.
Holds the information about one batch to be inferred.
void(* NvDsInferContextReturnInputAsyncFunc)(void *data)
Callback function type for returning the input client buffers back to the NvDsInferContext client asy...
char ** outputLayerNames
Array of output Layer Names.
Detectors will find objects and their coordinates in the input frame along with the class of the obje...
Holds the information about one detected object.
NvDsInferClassificationOutput classificationOutput
Classifier output.
char onnxFilePath[_PATH_MAX]
Path to the ONNX model file.
NvDsInferUffInputOrder uffInputOrder
Original input order for the UFF model.
Holds the information on all attributes classifed by a classifier network for one frame...
24-bit interleaved R-G-B
unsigned int numAttributes
Size of the attributes array.
NvDsInferDetectionOutput detectionOutput
Detector output.
NvDsInferFormat networkInputFormat
Network input format.
NvDsInferAttribute * attributes
Array of attributes.
Holds the information parsed from segmentation network output for one frame.
struct INvDsInferContext * NvDsInferContextHandle
An opaque pointer type to be used as an handle for the context instance.
char customNetworkConfigFilePath[_PATH_MAX]
Path to the config file for custom network creation.
const char * NvDsInferContext_GetLabel(NvDsInferContextHandle handle, unsigned int id, unsigned int value)
Get the string label associated with the class_id for detectors and the attribute id and the attribut...
unsigned int height
Height of the output.
char customBBoxParseFuncName[_MAX_STR_LENGTH]
Name of the custom bounding box function in the custom library.
Holds the information on all objects detected by a detector network in one frame. ...
void NvDsInferContext_ResetInitParams(NvDsInferContextInitParams *initParams)
Reset the members of initialization parameters to default values.
#define _MAX_CHANNELS
Maximum number of channels supported by the API for image input layers.
unsigned int height
Object height.
unsigned int left
Offset from the left boundary of the frame.
Failed to configure the NvDsInferContext instance possibly due to an erroneous initialization propert...
Segmentation - will classify each pixel into some finite possible classes.
unsigned int NvDsInferContext_GetNumLayersInfo(NvDsInferContextHandle handle)
Get the number of the bound layers of the inference engine in the NvDsInferContext instance...
32-bit interleaved R-G-B-A
char tltModelKey[_MAX_STR_LENGTH]
String key for decoding the TLT encoded model.
struct _NvDsInferContextInitParams NvDsInferContextInitParams
Holds the initialization parameters required for the NvDsInferContext interface.
unsigned int numObjects
Number of objects in the array.
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
char labelsFilePath[_PATH_MAX]
Path to the labels file containing strings for the class labels.
unsigned int classes
Number of classes supported by the network.
NvDsInferNetworkType
Enum for the type of the network.
char uffFilePath[_PATH_MAX]
Path to the UFF model file.
Unknown error was encountered.
unsigned int inputPitch
Pitch of the input frames, in bytes.
unsigned int width
Width of the output.
char modelFilePath[_PATH_MAX]
Path to the caffemodel file.
NvDsInferObject * objects
Array of objects.
Holds the information inferred by the network on one frame.
unsigned int top
Offset from the top boundary of the frame.
Holds information about the model network.
Definition: nvdsinfer.h:102
void ** hostBuffers
Array of pointers to set of host buffers for this batch.
float eps
Epsilon to control merging of overlapping boxes.
NvDsInferSegmentationOutput segmentationOutput
Classifier output.
Specifies dimensions of a layer with 3 dimensions.
Definition: nvdsinfer.h:54
char customLibPath[_PATH_MAX]
Path to the library containing custom methods required to support the network.
int useDLA
Boolean indicating if DLA should be used.
const char * NvDsInferContext_GetStatusName(NvDsInferStatus status)
Get the string name for the status.
int useDBScan
Boolean indicating if DBScan should be used for object clustering.
NvDsInferFrameOutput * frames
Array of outputs for each frame in the batch.
Holds information about one layer in the model.
Definition: nvdsinfer.h:82
char * label
String label for the classified output.
float threshold
Bounding box detection threshold.
void(* NvDsInferContextLoggingFunc)(NvDsInferContextHandle handle, unsigned int uniqueID, NvDsInferLogLevel logLevel, const char *funcName, const char *logMessage, void *userCtx)
Callback function type for logging the NvDsInferContext messages.
24-bit interleaved B-G-R
int groupThreshold
Minimum boxes in a cluster to be considered an object during grouping using OpenCV groupRectangles...
int * class_map
Pointer to the array for 2D pixel class map.
Other - Output layers will not be parsed by NvDsInferContext.
Classifiers - will classify the entire frame into some finite possible classes.
NvDsInferFormat inputFormat
Format of the frame contents.
float networkScaleFactor
Normalization factor to scale the input pixels with.
32-bit interleaved B-G-R-x
Custom Library interface implementation failed.
unsigned int outputBatchID
ID for the set of output buffers.
NvDsInferStatus NvDsInferContext_DequeueOutputBatch(NvDsInferContextHandle handle, NvDsInferContextBatchOutput *batchOutput)
Dequeue output for a batch of frames.
void * returnFuncData
Pointer to the data to be supplied with the return NvDsInferContextReturnInputAsyncFunc callback...
int minBoxes
Minimum boxes in a cluster to be considered an object during grouping using DBSCAN.
void ** outputDeviceBuffers
Array of pointers to set of output device buffers for this batch.
char customClassifierParseFuncName[_MAX_STR_LENGTH]
Name of the custom classifier attribute parsing function in the custom library.