NVIDIA DeepStream SDK API Reference

5.0 Release

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvdsinfer_custom_impl.h
Go to the documentation of this file.
1 
120 #ifndef _NVDSINFER_CUSTOM_IMPL_H_
121 #define _NVDSINFER_CUSTOM_IMPL_H_
122 
123 #include <string>
124 #include <vector>
125 
126 #pragma GCC diagnostic push
127 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
128 #include "NvCaffeParser.h"
129 #include "NvUffParser.h"
130 #pragma GCC diagnostic pop
131 
132 #include "nvdsinfer.h"
133 
134 /*
135  * C++ interfaces
136  */
137 #ifdef __cplusplus
138 
148 class IModelParser
149 {
150 public:
151  IModelParser() = default;
154  virtual ~IModelParser() = default;
155 
164  virtual NvDsInferStatus parseModel(
165  nvinfer1::INetworkDefinition& network) = 0;
166 
170  virtual bool hasFullDimsSupported() const = 0;
171 
176  virtual const char* getModelName() const = 0;
177 };
178 #endif
179 
180 /*
181  * C interfaces
182  */
183 
184 #ifdef __cplusplus
185 extern "C"
186 {
187 #endif
188 
192 typedef struct
193 {
197  unsigned int numClassesConfigured;
203  std::vector<float> perClassPreclusterThreshold;
204  /* Per class threshold to be applied post clustering operation */
205  std::vector<float> perClassPostclusterThreshold;
206 
209  std::vector<float> &perClassThreshold = perClassPreclusterThreshold;
211 
223 typedef bool (* NvDsInferParseCustomFunc) (
224  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
225  NvDsInferNetworkInfo const &networkInfo,
226  NvDsInferParseDetectionParams const &detectionParams,
227  std::vector<NvDsInferObjectDetectionInfo> &objectList);
228 
233 #define CHECK_CUSTOM_PARSE_FUNC_PROTOTYPE(customParseFunc) \
234  static void checkFunc_ ## customParseFunc (NvDsInferParseCustomFunc func = customParseFunc) \
235  { checkFunc_ ## customParseFunc (); }; \
236  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
237  NvDsInferNetworkInfo const &networkInfo, \
238  NvDsInferParseDetectionParams const &detectionParams, \
239  std::vector<NvDsInferObjectDetectionInfo> &objectList);
240 
255  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
256  NvDsInferNetworkInfo const &networkInfo,
257  float classifierThreshold,
258  std::vector<NvDsInferAttribute> &attrList,
259  std::string &descString);
260 
265 #define CHECK_CUSTOM_CLASSIFIER_PARSE_FUNC_PROTOTYPE(customParseFunc) \
266  static void checkFunc_ ## customParseFunc (NvDsInferClassiferParseCustomFunc func = customParseFunc) \
267  { checkFunc_ ## customParseFunc (); }; \
268  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
269  NvDsInferNetworkInfo const &networkInfo, \
270  float classifierThreshold, \
271  std::vector<NvDsInferAttribute> &attrList, \
272  std::string &descString);
273 
275 
307  nvinfer1::IBuilder * const builder,
308  const NvDsInferContextInitParams * const initParams,
309  nvinfer1::DataType dataType,
310  nvinfer1::ICudaEngine *& cudaEngine);
311 
316 #define CHECK_CUSTOM_ENGINE_CREATE_FUNC_PROTOTYPE(customEngineCreateFunc) \
317  static void checkFunc_ ## customEngineCreateFunc (NvDsInferEngineCreateCustomFunc = customEngineCreateFunc) \
318  { checkFunc_ ## customEngineCreateFunc(); }; \
319  extern "C" bool customEngineCreateFunc ( \
320  nvinfer1::IBuilder * const builder, \
321  const NvDsInferContextInitParams const *initParams, \
322  nvinfer1::DataType dataType, \
323  nvinfer1::ICudaEngine *& cudaEngine);
324 
328 typedef enum
329 {
339 
344 typedef union
345 {
346  nvcaffeparser1::IPluginFactory *pluginFactory;
347  nvcaffeparser1::IPluginFactoryExt *pluginFactoryExt;
348  nvcaffeparser1::IPluginFactoryV2 *pluginFactoryV2;
350 
355 typedef union
356 {
357  nvuffparser::IPluginFactory *pluginFactory;
358  nvuffparser::IPluginFactoryExt *pluginFactoryExt;
360 
378 
388 
405 
414 
425 bool NvDsInferPluginFactoryRuntimeGet (nvinfer1::IPluginFactory *& pluginFactory);
426 
434 void NvDsInferPluginFactoryRuntimeDestroy (nvinfer1::IPluginFactory * pluginFactory);
435 
451 bool NvDsInferInitializeInputLayers (std::vector<NvDsInferLayerInfo> const &inputLayersInfo,
452  NvDsInferNetworkInfo const &networkInfo,
453  unsigned int maxBatchSize);
458 bool NvDsInferCudaEngineGet(nvinfer1::IBuilder *builder,
459  NvDsInferContextInitParams *initParams,
460  nvinfer1::DataType dataType,
461  nvinfer1::ICudaEngine *& cudaEngine)
462  __attribute__((deprecated("Use 'engine-create-func-name' config parameter instead")));
463 
473 IModelParser* NvDsInferCreateModelParser(
474  const NvDsInferContextInitParams* initParams);
475 
476 #ifdef __cplusplus
477 }
478 #endif
479 
480 #endif
481 
unsigned int maxBatchSize
Holds the maximum number of frames to be inferred together in a batch.
std::vector< float > perClassPreclusterThreshold
Holds a per-class vector of detection confidence thresholds to be applied prior to clustering operati...
nvcaffeparser1::IPluginFactory * pluginFactory
void NvDsInferPluginFactoryRuntimeDestroy(nvinfer1::IPluginFactory *pluginFactory)
Destroys a Plugin Factory instance created by NvDsInferPluginFactoryRuntimeGet(). ...
Holds the initialization parameters required for the NvDsInferContext interface.
Holds the detection parameters required for parsing objects.
void NvDsInferPluginFactoryUffDestroy(NvDsInferPluginFactoryUff &pluginFactory)
Destroys a Plugin Factory instance created by NvDsInferPluginFactoryUffGet().
Specifies nvcaffeparser1::IPluginFactoryExt or nvuffparser::IPluginFactoryExt.
bool NvDsInferPluginFactoryRuntimeGet(nvinfer1::IPluginFactory *&pluginFactory)
Returns a new instance of a Plugin Factory interface to be used during parsing deserialization of CUD...
Specifies nvcaffeparser1::IPluginFactory or nvuffparser::IPluginFactory.
Copyright (c) 2017-2020, NVIDIA CORPORATION.
NvDsInferPluginFactoryType
Specifies the type of the Plugin Factory.
Holds a pointer to a heap-allocated Plugin Factory object required during UFF model parsing...
bool(* NvDsInferParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, NvDsInferParseDetectionParams const &detectionParams, std::vector< NvDsInferObjectDetectionInfo > &objectList)
Type definition for the custom bounding box parsing function.
bool NvDsInferCudaEngineGet(nvinfer1::IBuilder *builder, NvDsInferContextInitParams *initParams, nvinfer1::DataType dataType, nvinfer1::ICudaEngine *&cudaEngine) __attribute__((deprecated("Use 'engine-create-func-name' config parameter instead")))
The NvDsInferCudaEngineGet interface has been deprecated and has been replaced by NvDsInferEngineCrea...
Specifies nvcaffeparser1::IPluginFactoryV2.
Holds a pointer to a heap-allocated Plugin Factory object required during Caffe model parsing...
bool NvDsInferPluginFactoryUffGet(NvDsInferPluginFactoryUff &pluginFactory, NvDsInferPluginFactoryType &type)
Returns a new instance of a Plugin Factory interface to be used during parsing of UFF models...
bool(* NvDsInferEngineCreateCustomFunc)(nvinfer1::IBuilder *const builder, const NvDsInferContextInitParams *const initParams, nvinfer1::DataType dataType, nvinfer1::ICudaEngine *&cudaEngine)
Type definition for functions that build and return a CudaEngine for custom models.
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
Definition: nvdsinfer.h:178
unsigned int numClassesConfigured
Holds the number of classes requested to be parsed, starting with class ID 0.
nvuffparser::IPluginFactoryExt * pluginFactoryExt
bool(* NvDsInferClassiferParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, float classifierThreshold, std::vector< NvDsInferAttribute > &attrList, std::string &descString)
Type definition for the custom classifier output parsing function.
IModelParser * NvDsInferCreateModelParser(const NvDsInferContextInitParams *initParams)
Create a customized neural network parser for user-defined models.
bool NvDsInferInitializeInputLayers(std::vector< NvDsInferLayerInfo > const &inputLayersInfo, NvDsInferNetworkInfo const &networkInfo, unsigned int maxBatchSize)
Initializes the input layers for inference.
Holds information about the model network.
Definition: nvdsinfer.h:109
bool NvDsInferPluginFactoryCaffeGet(NvDsInferPluginFactoryCaffe &pluginFactory, NvDsInferPluginFactoryType &type)
Gets a new instance of a Plugin Factory interface to be used during parsing of Caffe models...
std::vector< float > perClassPostclusterThreshold
nvcaffeparser1::IPluginFactoryExt * pluginFactoryExt
nvuffparser::IPluginFactory * pluginFactory
void NvDsInferPluginFactoryCaffeDestroy(NvDsInferPluginFactoryCaffe &pluginFactory)
Destroys a Plugin Factory instance created by NvDsInferPluginFactoryCaffeGet().
nvcaffeparser1::IPluginFactoryV2 * pluginFactoryV2