NVIDIA DeepStream SDK API Reference

7.0 Release
nvdsinfer_custom_impl.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2017-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
119 #ifndef _NVDSINFER_CUSTOM_IMPL_H_
120 #define _NVDSINFER_CUSTOM_IMPL_H_
121 
122 #include <string>
123 #include <vector>
124 
125 #pragma GCC diagnostic push
126 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
127 #include "NvCaffeParser.h"
128 #include "NvUffParser.h"
129 #pragma GCC diagnostic pop
130 
131 #include "nvdsinfer.h"
132 
133 /*
134  * C++ interfaces
135  */
136 #ifdef __cplusplus
137 
147 class IModelParser
148 {
149 public:
150  IModelParser() = default;
153  virtual ~IModelParser() = default;
154 
163  virtual NvDsInferStatus parseModel(
164  nvinfer1::INetworkDefinition& network) = 0;
165 
169  virtual bool hasFullDimsSupported() const = 0;
170 
175  virtual const char* getModelName() const = 0;
176 };
177 #endif
178 
179 /*
180  * C interfaces
181  */
182 
183 #ifdef __cplusplus
184 extern "C"
185 {
186 #endif
187 
191 typedef struct
192 {
196  unsigned int numClassesConfigured;
202  std::vector<float> perClassPreclusterThreshold;
203  /* Per-class threshold to be applied after the clustering operation. */
204  std::vector<float> perClassPostclusterThreshold;
205 
208  std::vector<float> &perClassThreshold = perClassPreclusterThreshold;
210 
222 typedef bool (* NvDsInferParseCustomFunc) (
223  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
224  NvDsInferNetworkInfo const &networkInfo,
225  NvDsInferParseDetectionParams const &detectionParams,
226  std::vector<NvDsInferObjectDetectionInfo> &objectList);
227 
232 #define CHECK_CUSTOM_PARSE_FUNC_PROTOTYPE(customParseFunc) \
233  static void checkFunc_ ## customParseFunc (NvDsInferParseCustomFunc func = customParseFunc) \
234  { checkFunc_ ## customParseFunc (); }; \
235  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
236  NvDsInferNetworkInfo const &networkInfo, \
237  NvDsInferParseDetectionParams const &detectionParams, \
238  std::vector<NvDsInferObjectDetectionInfo> &objectList);
239 
252  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
253  NvDsInferNetworkInfo const &networkInfo,
254  NvDsInferParseDetectionParams const &detectionParams,
255  std::vector<NvDsInferInstanceMaskInfo> &objectList);
256 
261 #define CHECK_CUSTOM_INSTANCE_MASK_PARSE_FUNC_PROTOTYPE(customParseFunc) \
262  static void checkFunc_ ## customParseFunc (NvDsInferInstanceMaskParseCustomFunc func = customParseFunc) \
263  { checkFunc_ ## customParseFunc (); }; \
264  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
265  NvDsInferNetworkInfo const &networkInfo, \
266  NvDsInferParseDetectionParams const &detectionParams, \
267  std::vector<NvDsInferInstanceMaskInfo> &objectList);
268 
283  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
284  NvDsInferNetworkInfo const &networkInfo,
285  float classifierThreshold,
286  std::vector<NvDsInferAttribute> &attrList,
287  std::string &descString);
288 
293 #define CHECK_CUSTOM_CLASSIFIER_PARSE_FUNC_PROTOTYPE(customParseFunc) \
294  static void checkFunc_ ## customParseFunc (NvDsInferClassiferParseCustomFunc func = customParseFunc) \
295  { checkFunc_ ## customParseFunc (); }; \
296  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
297  NvDsInferNetworkInfo const &networkInfo, \
298  float classifierThreshold, \
299  std::vector<NvDsInferAttribute> &attrList, \
300  std::string &descString);
301 
320  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
321  NvDsInferNetworkInfo const &networkInfo,
322  float segmentationThreshold,
323  unsigned int numClasses,
324  int* classificationMap,
325  float*& classProbabilityMap);
326 
331 #define CHECK_CUSTOM_SEM_SEGMENTATION_PARSE_FUNC_PROTOTYPE(customParseFunc) \
332  static void checkFunc_ ## customParseFunc (NvDsInferSemSegmentationParseCustomFunc func = customParseFunc) \
333  { checkFunc_ ## customParseFunc (); }; \
334  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
335  NvDsInferNetworkInfo const &networkInfo, \
336  float segmentationThreshold, \
337  unsigned int numClasses, \
338  int* classificationMap, \
339  float*& classProbabilityMap);
340 
342 
375  nvinfer1::IBuilder * const builder, nvinfer1::IBuilderConfig * const builderConfig,
376  const NvDsInferContextInitParams * const initParams,
377  nvinfer1::DataType dataType,
378  nvinfer1::ICudaEngine *& cudaEngine);
379 
384 #define CHECK_CUSTOM_ENGINE_CREATE_FUNC_PROTOTYPE(customEngineCreateFunc) \
385  static void checkFunc_ ## customEngineCreateFunc (NvDsInferEngineCreateCustomFunc = customEngineCreateFunc) \
386  { checkFunc_ ## customEngineCreateFunc(); }; \
387  extern "C" bool customEngineCreateFunc ( \
388  nvinfer1::IBuilder * const builder, \
389  nvinfer1::IBuilderConfig * const builderConfig, \
390  const NvDsInferContextInitParams * const initParams, \
391  nvinfer1::DataType dataType, \
392  nvinfer1::ICudaEngine *& cudaEngine);
393 
397 typedef enum
398 {
402 
407 typedef union
408 {
409  nvcaffeparser1::IPluginFactoryV2 *pluginFactoryV2;
411 
429 
439 
450 bool NvDsInferPluginFactoryRuntimeGet (nvinfer1::IPluginFactory *& pluginFactory);
451 
459 void NvDsInferPluginFactoryRuntimeDestroy (nvinfer1::IPluginFactory * pluginFactory);
460 
476 bool NvDsInferInitializeInputLayers (std::vector<NvDsInferLayerInfo> const &inputLayersInfo,
477  NvDsInferNetworkInfo const &networkInfo,
478  unsigned int maxBatchSize);
483 bool NvDsInferCudaEngineGet(nvinfer1::IBuilder *builder,
484  NvDsInferContextInitParams *initParams,
485  nvinfer1::DataType dataType,
486  nvinfer1::ICudaEngine *& cudaEngine)
487  __attribute__((deprecated("Use 'engine-create-func-name' config parameter instead")));
488 
498 IModelParser* NvDsInferCreateModelParser(
499  const NvDsInferContextInitParams* initParams);
500 
501 #ifdef __cplusplus
502 }
503 #endif
504 
505 #endif
506 
NvDsInferParseDetectionParams::perClassPostclusterThreshold
std::vector< float > perClassPostclusterThreshold
Definition: nvdsinfer_custom_impl.h:204
NvDsInferInitializeInputLayers
bool NvDsInferInitializeInputLayers(std::vector< NvDsInferLayerInfo > const &inputLayersInfo, NvDsInferNetworkInfo const &networkInfo, unsigned int maxBatchSize)
Initializes the input layers for inference.
_NvDsInferContextInitParams::maxBatchSize
unsigned int maxBatchSize
Holds the maximum number of frames to be inferred together in a batch.
Definition: nvdsinfer_context.h:289
ds3d::DataType
DataType
Definition: idatatype.h:77
NvDsInferPluginFactoryCaffeDestroy
void NvDsInferPluginFactoryCaffeDestroy(NvDsInferPluginFactoryCaffe &pluginFactory)
Destroys a Plugin Factory instance created by NvDsInferPluginFactoryCaffeGet().
NvDsInferParseDetectionParams::numClassesConfigured
unsigned int numClassesConfigured
Holds the number of classes requested to be parsed, starting with class ID 0.
Definition: nvdsinfer_custom_impl.h:196
NvDsInferCudaEngineGet
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...
NvDsInferParseDetectionParams
Holds the detection parameters required for parsing objects.
Definition: nvdsinfer_custom_impl.h:191
NvDsInferInstanceMaskParseCustomFunc
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.
Definition: nvdsinfer_custom_impl.h:251
NvDsInferPluginFactoryType
NvDsInferPluginFactoryType
Specifies the type of the Plugin Factory.
Definition: nvdsinfer_custom_impl.h:397
NvDsInferPluginFactoryRuntimeGet
bool NvDsInferPluginFactoryRuntimeGet(nvinfer1::IPluginFactory *&pluginFactory)
Returns a new instance of a Plugin Factory interface to be used during parsing deserialization of CUD...
NvDsInferPluginFactoryCaffe::pluginFactoryV2
nvcaffeparser1::IPluginFactoryV2 * pluginFactoryV2
Definition: nvdsinfer_custom_impl.h:409
NvDsInferEngineCreateCustomFunc
bool(* NvDsInferEngineCreateCustomFunc)(nvinfer1::IBuilder *const builder, nvinfer1::IBuilderConfig *const builderConfig, const NvDsInferContextInitParams *const initParams, nvinfer1::DataType dataType, nvinfer1::ICudaEngine *&cudaEngine)
Type definition for functions that build and return a CudaEngine for custom models.
Definition: nvdsinfer_custom_impl.h:374
NvDsInferNetworkInfo
Holds information about the model network.
Definition: nvdsinfer.h:110
NvDsInferCreateModelParser
IModelParser * NvDsInferCreateModelParser(const NvDsInferContextInitParams *initParams)
Create a customized neural network parser for user-defined models.
NvDsInferPluginFactoryCaffe
Holds a pointer to a heap-allocated Plugin Factory object required during Caffe model parsing.
Definition: nvdsinfer_custom_impl.h:407
NvDsInferPluginFactoryRuntimeDestroy
void NvDsInferPluginFactoryRuntimeDestroy(nvinfer1::IPluginFactory *pluginFactory)
Destroys a Plugin Factory instance created by NvDsInferPluginFactoryRuntimeGet().
NvDsInferSemSegmentationParseCustomFunc
bool(* NvDsInferSemSegmentationParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, float segmentationThreshold, unsigned int numClasses, int *classificationMap, float *&classProbabilityMap)
Type definition for the custom semantic segmentation output parsing function.
Definition: nvdsinfer_custom_impl.h:319
NvDsInferClassiferParseCustomFunc
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.
Definition: nvdsinfer_custom_impl.h:282
NvDsInferParseDetectionParams::perClassPreclusterThreshold
std::vector< float > perClassPreclusterThreshold
Holds a per-class vector of detection confidence thresholds to be applied prior to the clustering ope...
Definition: nvdsinfer_custom_impl.h:202
PLUGIN_FACTORY_V2
@ PLUGIN_FACTORY_V2
Specifies nvcaffeparser1::IPluginFactoryV2.
Definition: nvdsinfer_custom_impl.h:400
NvDsInferParseCustomFunc
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.
Definition: nvdsinfer_custom_impl.h:222
_NvDsInferContextInitParams
Holds the initialization parameters required for the NvDsInferContext interface.
Definition: nvdsinfer_context.h:239
nvdsinfer.h
NvDsInferStatus
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
Definition: nvdsinfer.h:218
NvDsInferPluginFactoryCaffeGet
bool NvDsInferPluginFactoryCaffeGet(NvDsInferPluginFactoryCaffe &pluginFactory, NvDsInferPluginFactoryType &type)
Gets a new instance of a Plugin Factory interface to be used during parsing of Caffe models.