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 /*
2  * Copyright (c) 2017-2020, 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 
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 
253  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
254  NvDsInferNetworkInfo const &networkInfo,
255  NvDsInferParseDetectionParams const &detectionParams,
256  std::vector<NvDsInferInstanceMaskInfo> &objectList);
257 
262 #define CHECK_CUSTOM_INSTANCE_MASK_PARSE_FUNC_PROTOTYPE(customParseFunc) \
263  static void checkFunc_ ## customParseFunc (NvDsInferInstanceMaskParseCustomFunc func = customParseFunc) \
264  { checkFunc_ ## customParseFunc (); }; \
265  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
266  NvDsInferNetworkInfo const &networkInfo, \
267  NvDsInferParseDetectionParams const &detectionParams, \
268  std::vector<NvDsInferInstanceMaskInfo> &objectList);
269 
284  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
285  NvDsInferNetworkInfo const &networkInfo,
286  float classifierThreshold,
287  std::vector<NvDsInferAttribute> &attrList,
288  std::string &descString);
289 
294 #define CHECK_CUSTOM_CLASSIFIER_PARSE_FUNC_PROTOTYPE(customParseFunc) \
295  static void checkFunc_ ## customParseFunc (NvDsInferClassiferParseCustomFunc func = customParseFunc) \
296  { checkFunc_ ## customParseFunc (); }; \
297  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
298  NvDsInferNetworkInfo const &networkInfo, \
299  float classifierThreshold, \
300  std::vector<NvDsInferAttribute> &attrList, \
301  std::string &descString);
302 
304 
336  nvinfer1::IBuilder * const builder,
337  const NvDsInferContextInitParams * const initParams,
338  nvinfer1::DataType dataType,
339  nvinfer1::ICudaEngine *& cudaEngine);
340 
345 #define CHECK_CUSTOM_ENGINE_CREATE_FUNC_PROTOTYPE(customEngineCreateFunc) \
346  static void checkFunc_ ## customEngineCreateFunc (NvDsInferEngineCreateCustomFunc = customEngineCreateFunc) \
347  { checkFunc_ ## customEngineCreateFunc(); }; \
348  extern "C" bool customEngineCreateFunc ( \
349  nvinfer1::IBuilder * const builder, \
350  const NvDsInferContextInitParams const *initParams, \
351  nvinfer1::DataType dataType, \
352  nvinfer1::ICudaEngine *& cudaEngine);
353 
357 typedef enum
358 {
368 
373 typedef union
374 {
375  nvcaffeparser1::IPluginFactory *pluginFactory;
376  nvcaffeparser1::IPluginFactoryExt *pluginFactoryExt;
377  nvcaffeparser1::IPluginFactoryV2 *pluginFactoryV2;
379 
384 typedef union
385 {
386  nvuffparser::IPluginFactory *pluginFactory;
387  nvuffparser::IPluginFactoryExt *pluginFactoryExt;
389 
407 
417 
434 
443 
454 bool NvDsInferPluginFactoryRuntimeGet (nvinfer1::IPluginFactory *& pluginFactory);
455 
463 void NvDsInferPluginFactoryRuntimeDestroy (nvinfer1::IPluginFactory * pluginFactory);
464 
480 bool NvDsInferInitializeInputLayers (std::vector<NvDsInferLayerInfo> const &inputLayersInfo,
481  NvDsInferNetworkInfo const &networkInfo,
482  unsigned int maxBatchSize);
487 bool NvDsInferCudaEngineGet(nvinfer1::IBuilder *builder,
488  NvDsInferContextInitParams *initParams,
489  nvinfer1::DataType dataType,
490  nvinfer1::ICudaEngine *& cudaEngine)
491  __attribute__((deprecated("Use 'engine-create-func-name' config parameter instead")));
492 
502 IModelParser* NvDsInferCreateModelParser(
503  const NvDsInferContextInitParams* initParams);
504 
505 #ifdef __cplusplus
506 }
507 #endif
508 
509 #endif
510 
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.
bool(* NvDsInferInstanceMaskParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, NvDsInferParseDetectionParams const &detectionParams, std::vector< NvDsInferInstanceMaskInfo > &objectList)
Type definition for the custom bounding box and instance mask parsing function.
NVIDIA DeepStream inference specifications
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:209
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