NVIDIA DeepStream SDK API Reference

7.1 Release
nvdsinfer_custom_impl.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2017-2024 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 
110 #ifndef _NVDSINFER_CUSTOM_IMPL_H_
111 #define _NVDSINFER_CUSTOM_IMPL_H_
112 
113 #include <string>
114 #include <vector>
115 
116 #include "nvdsinfer.h"
117 #include <NvInfer.h>
118 #include <NvInferRuntime.h>
119 #include <NvOnnxParser.h>
120 
121 /*
122  * C++ interfaces
123  */
124 #ifdef __cplusplus
125 
135 class IModelParser
136 {
137 public:
138  IModelParser() = default;
141  virtual ~IModelParser() = default;
142 
151  virtual NvDsInferStatus parseModel(
152  nvinfer1::INetworkDefinition& network) = 0;
153 
157  virtual bool hasFullDimsSupported() const = 0;
158 
163  virtual const char* getModelName() const = 0;
164 };
165 #endif
166 
167 /*
168  * C interfaces
169  */
170 
171 #ifdef __cplusplus
172 extern "C"
173 {
174 #endif
175 
179 typedef struct
180 {
184  unsigned int numClassesConfigured;
190  std::vector<float> perClassPreclusterThreshold;
191  /* Per-class threshold to be applied after the clustering operation. */
192  std::vector<float> perClassPostclusterThreshold;
193 
196  std::vector<float> &perClassThreshold = perClassPreclusterThreshold;
198 
210 typedef bool (* NvDsInferParseCustomFunc) (
211  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
212  NvDsInferNetworkInfo const &networkInfo,
213  NvDsInferParseDetectionParams const &detectionParams,
214  std::vector<NvDsInferObjectDetectionInfo> &objectList);
215 
220 #define CHECK_CUSTOM_PARSE_FUNC_PROTOTYPE(customParseFunc) \
221  static void checkFunc_ ## customParseFunc (NvDsInferParseCustomFunc func = customParseFunc) \
222  { checkFunc_ ## customParseFunc (); }; \
223  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
224  NvDsInferNetworkInfo const &networkInfo, \
225  NvDsInferParseDetectionParams const &detectionParams, \
226  std::vector<NvDsInferObjectDetectionInfo> &objectList);
227 
240  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
241  NvDsInferNetworkInfo const &networkInfo,
242  NvDsInferParseDetectionParams const &detectionParams,
243  std::vector<NvDsInferInstanceMaskInfo> &objectList);
244 
249 #define CHECK_CUSTOM_INSTANCE_MASK_PARSE_FUNC_PROTOTYPE(customParseFunc) \
250  static void checkFunc_ ## customParseFunc (NvDsInferInstanceMaskParseCustomFunc func = customParseFunc) \
251  { checkFunc_ ## customParseFunc (); }; \
252  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
253  NvDsInferNetworkInfo const &networkInfo, \
254  NvDsInferParseDetectionParams const &detectionParams, \
255  std::vector<NvDsInferInstanceMaskInfo> &objectList);
256 
271  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
272  NvDsInferNetworkInfo const &networkInfo,
273  float classifierThreshold,
274  std::vector<NvDsInferAttribute> &attrList,
275  std::string &descString);
276 
281 #define CHECK_CUSTOM_CLASSIFIER_PARSE_FUNC_PROTOTYPE(customParseFunc) \
282  static void checkFunc_ ## customParseFunc (NvDsInferClassiferParseCustomFunc func = customParseFunc) \
283  { checkFunc_ ## customParseFunc (); }; \
284  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
285  NvDsInferNetworkInfo const &networkInfo, \
286  float classifierThreshold, \
287  std::vector<NvDsInferAttribute> &attrList, \
288  std::string &descString);
289 
308  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
309  NvDsInferNetworkInfo const &networkInfo,
310  float segmentationThreshold,
311  unsigned int numClasses,
312  int* classificationMap,
313  float*& classProbabilityMap);
314 
319 #define CHECK_CUSTOM_SEM_SEGMENTATION_PARSE_FUNC_PROTOTYPE(customParseFunc) \
320  static void checkFunc_ ## customParseFunc (NvDsInferSemSegmentationParseCustomFunc func = customParseFunc) \
321  { checkFunc_ ## customParseFunc (); }; \
322  extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
323  NvDsInferNetworkInfo const &networkInfo, \
324  float segmentationThreshold, \
325  unsigned int numClasses, \
326  int* classificationMap, \
327  float*& classProbabilityMap);
328 
330 
363  nvinfer1::IBuilder * const builder, nvinfer1::IBuilderConfig * const builderConfig,
364  const NvDsInferContextInitParams * const initParams,
365  nvinfer1::DataType dataType,
366  nvinfer1::ICudaEngine *& cudaEngine);
367 
372 #define CHECK_CUSTOM_ENGINE_CREATE_FUNC_PROTOTYPE(customEngineCreateFunc) \
373  static void checkFunc_ ## customEngineCreateFunc (NvDsInferEngineCreateCustomFunc = customEngineCreateFunc) \
374  { checkFunc_ ## customEngineCreateFunc(); }; \
375  extern "C" bool customEngineCreateFunc ( \
376  nvinfer1::IBuilder * const builder, \
377  nvinfer1::IBuilderConfig * const builderConfig, \
378  const NvDsInferContextInitParams * const initParams, \
379  nvinfer1::DataType dataType, \
380  nvinfer1::ICudaEngine *& cudaEngine);
381 
392 bool NvDsInferPluginFactoryRuntimeGet (nvinfer1::IPluginFactory *& pluginFactory);
393 
401 void NvDsInferPluginFactoryRuntimeDestroy (nvinfer1::IPluginFactory * pluginFactory);
402 
418 bool NvDsInferInitializeInputLayers (std::vector<NvDsInferLayerInfo> const &inputLayersInfo,
419  NvDsInferNetworkInfo const &networkInfo,
420  unsigned int maxBatchSize);
425 bool NvDsInferCudaEngineGet(nvinfer1::IBuilder *builder,
426  NvDsInferContextInitParams *initParams,
427  nvinfer1::DataType dataType,
428  nvinfer1::ICudaEngine *& cudaEngine)
429  __attribute__((deprecated("Use 'engine-create-func-name' config parameter instead")));
430 
440 IModelParser* NvDsInferCreateModelParser(
441  const NvDsInferContextInitParams* initParams);
442 
443 #ifdef __cplusplus
444 }
445 #endif
446 
447 #endif
448 
NvDsInferParseDetectionParams::perClassPostclusterThreshold
std::vector< float > perClassPostclusterThreshold
Definition: nvdsinfer_custom_impl.h:192
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
NvDsInferParseDetectionParams::numClassesConfigured
unsigned int numClassesConfigured
Holds the number of classes requested to be parsed, starting with class ID 0.
Definition: nvdsinfer_custom_impl.h:184
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:179
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:239
NvDsInferPluginFactoryRuntimeGet
bool NvDsInferPluginFactoryRuntimeGet(nvinfer1::IPluginFactory *&pluginFactory)
Returns a new instance of a Plugin Factory interface to be used during parsing deserialization of CUD...
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:362
NvDsInferNetworkInfo
Holds information about the model network.
Definition: nvdsinfer.h:112
NvDsInferCreateModelParser
IModelParser * NvDsInferCreateModelParser(const NvDsInferContextInitParams *initParams)
Create a customized neural network parser for user-defined models.
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:307
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:270
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:190
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:210
_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:220