NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2018-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __NVDSINFER_CONTEXT_IMPL_H__
19 #define __NVDSINFER_CONTEXT_IMPL_H__
20 
21 #include <stdarg.h>
22 #include <condition_variable>
23 #include <functional>
24 #include <list>
25 #include <memory>
26 #include <mutex>
27 #include <queue>
28 #include <iostream>
29 #include <fstream>
30 
31 #include <NvInfer.h>
32 #include <cuda_runtime_api.h>
33 
34 #pragma GCC diagnostic push
35 #if __GNUC__ >= 8
36 #pragma GCC diagnostic ignored "-Wclass-memaccess"
37 #endif
38 #ifdef WITH_OPENCV
39 #include <opencv2/objdetect/objdetect.hpp>
40 #endif
41 #pragma GCC diagnostic pop
42 
43 #include <nvdsinfer_context.h>
44 #include <nvdsinfer_custom_impl.h>
45 #include <nvdsinfer_utils.h>
46 #include <nvdsinfer_logger.h>
47 
48 #include "nvdsinfer_backend.h"
49 
50 namespace nvdsinfer {
51 
53  std::function<void(NvDsInferLogLevel, const char* msg)>;
54 
58 typedef struct
59 {
60  std::vector<void*> m_DeviceBuffers;
61  std::vector<std::unique_ptr<CudaHostBuffer>> m_HostBuffers;
62 
63  std::vector<std::unique_ptr<CudaDeviceBuffer>> m_OutputDeviceBuffers;
64 
65  unsigned int m_BatchSize = 0;
66  std::unique_ptr<CudaEvent> m_OutputCopyDoneEvent = nullptr;
67  bool m_BuffersWithContext = true;
68 
69 } NvDsInferBatch;
70 
74 class InferPreprocessor
75 {
76 public:
78  const NvDsInferBatchDimsLayerInfo& layerInfo, int id = 0);
79  virtual ~InferPreprocessor() = default;
80 
82  {
83  m_LoggingFunc = func;
84  }
85  bool setScaleOffsets(float scale, const std::vector<float>& offsets = {});
86  bool setMeanFile(const std::string& file);
87  bool setInputOrder(const NvDsInferTensorOrder order);
88 
91 
93  void* devBuf, CudaStream& mainStream, CudaEvent* waitingEvent);
94 
95 private:
96  NvDsInferStatus readMeanImageFile();
97  DISABLE_CLASS_COPY(InferPreprocessor);
98 
99 private:
100  int m_UniqueID = 0;
101  NvDsInferLoggingFunc m_LoggingFunc;
102 
103  NvDsInferNetworkInfo m_NetworkInfo = {0};
105  NvDsInferFormat m_NetworkInputFormat = NvDsInferFormat_RGB;
107  NvDsInferBatchDimsLayerInfo m_NetworkInputLayer;
108  float m_Scale = 1.0f;
109  std::vector<float> m_ChannelMeans; // same as channels
110  std::string m_MeanFile;
111 
112  std::unique_ptr<CudaStream> m_PreProcessStream;
113  /* Cuda Event for synchronizing completion of pre-processing. */
114  std::shared_ptr<CudaEvent> m_PreProcessCompleteEvent;
115  std::unique_ptr<CudaDeviceBuffer> m_MeanDataBuffer;
116 };
117 
121 class InferPostprocessor
122 {
123 protected:
124  InferPostprocessor(NvDsInferNetworkType type, int id, int gpuId)
125  : m_NetworkType(type), m_UniqueID(id), m_GpuID(gpuId) {}
126 
127 public:
128  virtual ~InferPostprocessor();
129  void setDlHandle(const std::shared_ptr<DlLibHandle>& dlHandle)
130  {
131  m_CustomLibHandle = dlHandle;
132  }
134  {
135  m_NetworkInfo = info;
136  }
137  void setAllLayerInfo(std::vector<NvDsInferBatchDimsLayerInfo>& info)
138  {
139  m_AllLayerInfo.resize(info.size());
140  std::copy(info.begin(), info.end(), m_AllLayerInfo.begin());
141  }
142  void setOutputLayerInfo(std::vector<NvDsInferBatchDimsLayerInfo>& info)
143  {
144  m_OutputLayerInfo.resize(info.size());
145  std::copy(info.begin(), info.end(), m_OutputLayerInfo.begin());
146  }
148  {
149  m_LoggingFunc = func;
150  }
151  const std::vector<std::vector<std::string>>& getLabels() const
152  {
153  return m_Labels;
154  }
155  bool needInputCopy() const { return m_CopyInputToHostBuffers; }
156 
158 
160  const NvDsInferContextInitParams& initParams);
161 
162  /* Copy inference output from device to host memory. */
164  NvDsInferBatch& buffer, CudaStream& mainStream);
165 
168 
169  void freeBatchOutput(NvDsInferContextBatchOutput& batchOutput);
170 
171 private:
172  /* Parse the output of each frame in batch. */
173  virtual NvDsInferStatus parseEachBatch(
174  const std::vector<NvDsInferLayerInfo>& outputLayers,
175  NvDsInferFrameOutput& result) = 0;
176 
177 protected:
178  NvDsInferStatus parseLabelsFile(const std::string& path);
180  void releaseFrameOutput(NvDsInferFrameOutput& frameOutput);
181 
182 private:
183  DISABLE_CLASS_COPY(InferPostprocessor);
184 
185 protected:
186  /* Processor type */
188 
189  int m_UniqueID = 0;
190  uint32_t m_GpuID = 0;
192 
193  /* Custom library implementation. */
194  std::shared_ptr<DlLibHandle> m_CustomLibHandle;
195  bool m_CopyInputToHostBuffers = false;
196  bool m_disableOutputHostCopy = false;
197  bool m_DumpOpTensor = false;
198  std::vector<std::pair<std::string, std::string>> m_DumpOpTensorFiles;
199  bool m_OverwriteOpTensor = false;
200  std::vector<std::pair<std::string, int>> m_OverwriteOpTensorFilePairs;
201  std::vector<std::ifstream *> m_OverwriteOpTensorFiles;
202  /* Network input information. */
204  std::vector<NvDsInferLayerInfo> m_AllLayerInfo;
205  std::vector<NvDsInferLayerInfo> m_OutputLayerInfo;
206 
207  /* Holds the string labels for classes. */
208  std::vector<std::vector<std::string>> m_Labels;
209 };
210 
212 class DetectPostprocessor : public InferPostprocessor
213 {
214 public:
215  DetectPostprocessor(int id, int gpuId = 0)
217  ~DetectPostprocessor() override = default;
218 
220  const NvDsInferContextInitParams& initParams) override;
221 
222 private:
223  NvDsInferStatus parseEachBatch(
224  const std::vector<NvDsInferLayerInfo>& outputLayers,
225  NvDsInferFrameOutput& result) override;
226 
227  bool parseBoundingBox(
228  std::vector<NvDsInferLayerInfo> const& outputLayersInfo,
229  NvDsInferNetworkInfo const& networkInfo,
230  NvDsInferParseDetectionParams const& detectionParams,
231  std::vector<NvDsInferObjectDetectionInfo>& objectList);
232 
233  std::vector<int> nonMaximumSuppression
234  (std::vector<std::pair<float, int>>& scoreIndex,
235  std::vector<NvDsInferParseObjectInfo>& bbox,
236  const float nmsThreshold);
237  void clusterAndFillDetectionOutputNMS(NvDsInferDetectionOutput &output);
238  void clusterAndFillDetectionOutputCV(NvDsInferDetectionOutput& output);
239  void clusterAndFillDetectionOutputDBSCAN(NvDsInferDetectionOutput& output);
240  void clusterAndFillDetectionOutputHybrid(NvDsInferDetectionOutput& output);
241  void fillUnclusteredOutput(NvDsInferDetectionOutput& output);
242  NvDsInferStatus fillDetectionOutput(
243  const std::vector<NvDsInferLayerInfo>& outputLayers,
244  NvDsInferDetectionOutput& output);
245  void preClusteringThreshold(NvDsInferParseDetectionParams const &detectionParams,
246  std::vector<NvDsInferObjectDetectionInfo> &objectList);
247  void filterTopKOutputs(const int topK,
248  std::vector<NvDsInferObjectDetectionInfo> &objectList);
249 
250 private:
251  _DS_DEPRECATED_("Use m_ClusterMode instead")
252  bool m_UseDBScan = false;
253  std::shared_ptr<NvDsInferDBScan> m_DBScanHandle;
254  NvDsInferClusterMode m_ClusterMode;
255 
256  /* Number of classes detected by the model. */
257  uint32_t m_NumDetectedClasses = 0;
258 
259  /* Detection / grouping parameters. */
260  std::vector<NvDsInferDetectionParams> m_PerClassDetectionParams;
261  NvDsInferParseDetectionParams m_DetectionParams = {0, {}, {}};
262 
263  /* Vector for all parsed objects. */
264  std::vector<NvDsInferObjectDetectionInfo> m_ObjectList;
265 #ifdef WITH_OPENCV
266  /* Vector of cv::Rect vectors for each class. */
267  std::vector<std::vector<cv::Rect>> m_PerClassCvRectList;
268 #endif
269  /* Vector of NvDsInferObjectDetectionInfo vectors for each class. */
270  std::vector<std::vector<NvDsInferObjectDetectionInfo>> m_PerClassObjectList;
271 
272  NvDsInferParseCustomFunc m_CustomBBoxParseFunc = nullptr;
273 };
274 
276 class InstanceSegmentPostprocessor : public InferPostprocessor
277 {
278 public:
279  InstanceSegmentPostprocessor(int id, int gpuId = 0)
281  ~InstanceSegmentPostprocessor() override = default;
282 
284  const NvDsInferContextInitParams& initParams) override;
285 
286 private:
287  NvDsInferStatus parseEachBatch(
288  const std::vector<NvDsInferLayerInfo>& outputLayers,
289  NvDsInferFrameOutput& result) override;
290 
291  void fillUnclusteredOutput(NvDsInferDetectionOutput& output);
292  NvDsInferStatus fillDetectionOutput(
293  const std::vector<NvDsInferLayerInfo>& outputLayers,
294  NvDsInferDetectionOutput& output);
295  void preClusteringThreshold(NvDsInferParseDetectionParams const &detectionParams,
296  std::vector<NvDsInferInstanceMaskInfo> &objectList);
297  void filterTopKOutputs(const int topK,
298  std::vector<NvDsInferInstanceMaskInfo> &objectList);
299 
300 private:
301  NvDsInferClusterMode m_ClusterMode;
302 
303  /* Number of classes detected by the model. */
304  uint32_t m_NumDetectedClasses = 0;
305 
306  /* Detection / grouping parameters. */
307  std::vector<NvDsInferDetectionParams> m_PerClassDetectionParams;
308  NvDsInferParseDetectionParams m_DetectionParams = {0, {}, {}};
309 
310  /* Vector for all parsed instance masks. */
311  std::vector<NvDsInferInstanceMaskInfo> m_InstanceMaskList;
312  /* Vector of NvDsInferInstanceMaskInfo vectors for each class. */
313  std::vector<std::vector<NvDsInferInstanceMaskInfo>> m_PerClassInstanceMaskList;
314 
315  NvDsInferInstanceMaskParseCustomFunc m_CustomParseFunc = nullptr;
316 };
317 
319 class ClassifyPostprocessor : public InferPostprocessor
320 {
321 public:
322  ClassifyPostprocessor(int id, int gpuId = 0)
324 
326  const NvDsInferContextInitParams& initParams) override;
327 
328 private:
329  NvDsInferStatus parseEachBatch(
330  const std::vector<NvDsInferLayerInfo>& outputLayers,
331  NvDsInferFrameOutput& result) override;
332 
333  NvDsInferStatus fillClassificationOutput(
334  const std::vector<NvDsInferLayerInfo>& outputLayers,
336 
337  bool parseAttributesFromSoftmaxLayers(
338  std::vector<NvDsInferLayerInfo> const& outputLayersInfo,
339  NvDsInferNetworkInfo const& networkInfo, float classifierThreshold,
340  std::vector<NvDsInferAttribute>& attrList, std::string& attrString);
341 
342 private:
343  float m_ClassifierThreshold = 0.0f;
344  NvDsInferClassiferParseCustomFunc m_CustomClassifierParseFunc = nullptr;
345 };
346 
348 class SegmentPostprocessor : public InferPostprocessor
349 {
350 public:
351  SegmentPostprocessor(int id, int gpuId = 0)
353 
355  const NvDsInferContextInitParams& initParams) override;
356 
357 private:
358  NvDsInferStatus parseEachBatch(
359  const std::vector<NvDsInferLayerInfo>& outputLayers,
360  NvDsInferFrameOutput& result) override;
361 
362  NvDsInferStatus fillSegmentationOutput(
363  const std::vector<NvDsInferLayerInfo>& outputLayers,
365 
366  bool parseSemanticSegmentationOutput(
367  std::vector<NvDsInferLayerInfo> const& outputLayersInfo,
368  NvDsInferNetworkInfo const& networkInfo,
369  float segmentationThreshold, unsigned int numClasses,
370  int* classificationMap, float*& classProbabilityMap);
371 
372 private:
373  float m_SegmentationThreshold = 0.0f;
374  NvDsInferTensorOrder m_SegmentationOutputOrder = NvDsInferTensorOrder_kNCHW;
375  NvDsInferSemSegmentationParseCustomFunc m_CustomSegmentationParseFunc = nullptr;
376  uint32_t m_NumSegmentationClasses = 0;
377 };
378 
379 class OtherPostprocessor : public InferPostprocessor
380 {
381 public:
382  OtherPostprocessor(int id, int gpuId = 0)
384 
386  const NvDsInferContextInitParams& initParams) override;
387 
388 private:
389  NvDsInferStatus parseEachBatch(
390  const std::vector<NvDsInferLayerInfo>& outputLayers,
391  NvDsInferFrameOutput& result) override {
392  return NVDSINFER_SUCCESS;
393  }
394 };
395 
396 class BackendContext;
397 
401 class NvDsInferContextImpl : public INvDsInferContext
402 {
403 public:
408 
414  void *userCtx, NvDsInferContextLoggingFunc logFunc);
415 
416 private:
420  ~NvDsInferContextImpl() override;
421 
422  /* Implementation of the public methods of INvDsInferContext interface. */
423  NvDsInferStatus queueInputBatch(NvDsInferContextBatchInput &batchInput) override;
424  NvDsInferStatus queueInputBatchPreprocessed(NvDsInferContextBatchPreprocessedInput &batchInput) override;
425  NvDsInferStatus dequeueOutputBatch(NvDsInferContextBatchOutput &batchOutput) override;
426  void releaseBatchOutput(NvDsInferContextBatchOutput &batchOutput) override;
427  void fillLayersInfo(std::vector<NvDsInferLayerInfo> &layersInfo) override;
428  void getNetworkInfo(NvDsInferNetworkInfo &networkInfo) override;
429  const std::vector<std::vector<std::string>>& getLabels() override;
430  void destroy() override;
431 
432  /* Other private methods. */
433  NvDsInferStatus initInferenceInfo(
434  const NvDsInferContextInitParams& initParams, BackendContext& ctx);
435  NvDsInferStatus preparePreprocess(
436  const NvDsInferContextInitParams& initParams);
437  NvDsInferStatus preparePostprocess(
438  const NvDsInferContextInitParams& initParams);
439 
440  std::unique_ptr<BackendContext> generateBackendContext(
441  NvDsInferContextInitParams& initParams);
442  std::unique_ptr<BackendContext> buildModel(
443  NvDsInferContextInitParams& initParams);
444  bool deserializeEngineAndBackend(const std::string enginePath, int dla,
445  std::shared_ptr<TrtEngine>& engine,
446  std::unique_ptr<BackendContext>& backend);
447  NvDsInferStatus checkBackendParams(
448  BackendContext& ctx, const NvDsInferContextInitParams& initParams);
449 
450  NvDsInferStatus getBoundLayersInfo();
451  NvDsInferStatus resizeOutputBufferpool(uint32_t numBuffers);
452  NvDsInferStatus allocateBuffers();
453  NvDsInferStatus initNonImageInputLayers();
454  NvDsInferStatus warmupEngine();
455 
456  /* Input layer has a binding index of 0 */
457  static const int INPUT_LAYER_INDEX = 0;
458 
461  uint32_t m_UniqueID = 0;
462  uint32_t m_GpuID = 0;
463 
464  /* Custom unique_ptrs. These TensorRT objects will get deleted automatically
465  * when the NvDsInferContext object is deleted. */
466  std::unique_ptr<BackendContext> m_BackendContext;
467  std::shared_ptr<DlLibHandle> m_CustomLibHandle;
468 
469  std::unique_ptr<InferPreprocessor> m_Preprocessor;
470  std::unique_ptr<InferPostprocessor> m_Postprocessor;
471 
472  uint32_t m_MaxBatchSize = 0;
473  /* Network input information. */
474  NvDsInferNetworkInfo m_NetworkInfo;
475 
476  /* Vectors for holding information about bound layers. */
477  std::vector<NvDsInferBatchDimsLayerInfo> m_AllLayerInfo;
478  std::vector<NvDsInferBatchDimsLayerInfo> m_OutputLayerInfo;
479  NvDsInferBatchDimsLayerInfo m_InputImageLayerInfo;
480 
481  std::vector<void *> m_BindingBuffers;
482  std::vector<std::unique_ptr<CudaDeviceBuffer>> m_InputDeviceBuffers;
483 
484  uint32_t m_OutputBufferPoolSize = NVDSINFER_MIN_OUTPUT_BUFFERPOOL_SIZE;
485  std::vector<std::shared_ptr<NvDsInferBatch>> m_Batches;
486  std::mutex m_BatchesMutex;
487 
488  /* Queues and synchronization members for processing multiple batches
489  * in parallel.
490  */
491  GuardQueue<std::list<NvDsInferBatch*>> m_FreeBatchQueue;
492  GuardQueue<std::list<NvDsInferBatch*>> m_ProcessBatchQueue;
493 
494  std::unique_ptr<CudaStream> m_InferStream;
495  std::unique_ptr<CudaStream> m_PostprocessStream;
496 
497  /* Cuda Event for synchronizing input consumption by TensorRT CUDA engine. */
498  std::shared_ptr<CudaEvent> m_InputConsumedEvent;
499 
500  /* Cuda Event for synchronizing infer completion by TensorRT CUDA engine. */
501  std::shared_ptr<CudaEvent> m_InferCompleteEvent;
502 
503  NvDsInferLoggingFunc m_LoggingFunc;
504 
505  bool m_Initialized = false;
506  uint32_t m_AutoIncMem = 1;
507  double m_MaxGPUMem = 99;
508  bool m_DumpIpTensor = false;
509  std::string m_DumpIpTensorFilePath = " ";
510  bool m_OverwriteIpTensor = false;
511  std::string m_OverwriteIpTensorFilePath = " ";
512  std::ifstream m_OverwriteIpTensorFile;
513 };
514 
515 }
516 
517 #define printMsg(level, tag_str, fmt, ...) \
518  do { \
519  char* baseName = strrchr((char*)__FILE__, '/'); \
520  baseName = (baseName) ? (baseName + 1) : (char*)__FILE__; \
521  char logMsgBuffer[5 * _MAX_STR_LENGTH + 1]; \
522  snprintf(logMsgBuffer, 5 * _MAX_STR_LENGTH, \
523  tag_str " NvDsInferContextImpl::%s() <%s:%d> [UID = %d]: " fmt, \
524  __func__, baseName, __LINE__, m_UniqueID, ##__VA_ARGS__); \
525  if (m_LoggingFunc) { \
526  m_LoggingFunc(level, logMsgBuffer); \
527  } else { \
528  fprintf(stderr, "%s\n", logMsgBuffer); \
529  } \
530  } while (0)
531 
532 #define printError(fmt, ...) \
533  do { \
534  printMsg (NVDSINFER_LOG_ERROR, "Error in", fmt, ##__VA_ARGS__); \
535  } while (0)
536 
537 #define printWarning(fmt, ...) \
538  do { \
539  printMsg (NVDSINFER_LOG_WARNING, "Warning from", fmt, ##__VA_ARGS__); \
540  } while (0)
541 
542 #define printInfo(fmt, ...) \
543  do { \
544  printMsg (NVDSINFER_LOG_INFO, "Info from", fmt, ##__VA_ARGS__); \
545  } while (0)
546 
547 #define printDebug(fmt, ...) \
548  do { \
549  printMsg (NVDSINFER_LOG_DEBUG, "DEBUG", fmt, ##__VA_ARGS__); \
550  } while (0)
551 
552 #endif
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: sources/includes/nvdsinfer_custom_impl.h:275
nvdsinfer::InferPostprocessor::setAllLayerInfo
void setAllLayerInfo(std::vector< NvDsInferBatchDimsLayerInfo > &info)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:137
nvdsinfer::DetectPostprocessor::~DetectPostprocessor
~DetectPostprocessor() override=default
nvdsinfer::InferPreprocessor::setLoggingFunc
void setLoggingFunc(const NvDsInferLoggingFunc &func)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:81
nvdsinfer::InferPreprocessor::setMeanFile
bool setMeanFile(const std::string &file)
NvDsInferTensorOrder
NvDsInferTensorOrder
Defines UFF input layer orders.
Definition: sources/includes/nvdsinfer_context.h:183
NvDsInferNetworkType_Classifier
@ NvDsInferNetworkType_Classifier
Specifies a classifier.
Definition: sources/includes/nvdsinfer_context.h:145
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: sources/includes/nvdsinfer_custom_impl.h:312
nvdsinfer::DetectPostprocessor::DetectPostprocessor
DetectPostprocessor(int id, int gpuId=0)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:215
nvdsinfer::InferPostprocessor::initResource
virtual NvDsInferStatus initResource(const NvDsInferContextInitParams &initParams)
NvDsInferFormat
NvDsInferFormat
Defines color formats.
Definition: sources/includes/nvdsinfer_context.h:163
nvdsinfer::InferPostprocessor::m_AllLayerInfo
std::vector< NvDsInferLayerInfo > m_AllLayerInfo
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:204
nvdsinfer::InferPostprocessor::setLoggingFunc
void setLoggingFunc(const NvDsInferLoggingFunc &func)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:147
nvdsinfer::InferPostprocessor::m_CustomLibHandle
std::shared_ptr< DlLibHandle > m_CustomLibHandle
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:194
nvdsinfer::InferPostprocessor::needOutputCopyB4Processing
bool needOutputCopyB4Processing() const
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:157
nvdsinfer::InferPostprocessor::~InferPostprocessor
virtual ~InferPostprocessor()
nvdsinfer::CudaStream
Helper class for managing Cuda Streams.
Definition: sources/libs/nvdsinfer/nvdsinfer_backend.h:44
nvdsinfer::InferPostprocessor::m_GpuID
uint32_t m_GpuID
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:190
nvdsinfer::InferPostprocessor::releaseFrameOutput
void releaseFrameOutput(NvDsInferFrameOutput &frameOutput)
nvdsinfer::InferPostprocessor::getLabels
const std::vector< std::vector< std::string > > & getLabels() const
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:151
NvDsInferSegmentationOutput
Holds information parsed from segmentation network output for one frame.
Definition: sources/includes/nvdsinfer_context.h:599
nvdsinfer::InferPostprocessor::allocDeviceResource
NvDsInferStatus allocDeviceResource()
nvdsinfer::InferPostprocessor::setDlHandle
void setDlHandle(const std::shared_ptr< DlLibHandle > &dlHandle)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:129
nvdsinfer::InferPostprocessor::needInputCopy
bool needInputCopy() const
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:155
NVDSINFER_SUCCESS
@ NVDSINFER_SUCCESS
NvDsInferContext operation succeeded.
Definition: sources/includes/nvdsinfer.h:233
nvdsinfer::InferPostprocessor::postProcessHost
virtual NvDsInferStatus postProcessHost(NvDsInferBatch &buffer, NvDsInferContextBatchOutput &output)
nvdsinfer::InferPostprocessor::setOutputLayerInfo
void setOutputLayerInfo(std::vector< NvDsInferBatchDimsLayerInfo > &info)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:142
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: sources/includes/nvdsinfer_custom_impl.h:244
nvdsinfer::InferPostprocessor::freeBatchOutput
void freeBatchOutput(NvDsInferContextBatchOutput &batchOutput)
nvdsinfer::InferPostprocessor::m_disableOutputHostCopy
bool m_disableOutputHostCopy
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:196
nvdsinfer::InferPostprocessor::m_OverwriteOpTensor
bool m_OverwriteOpTensor
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:199
nvdsinfer::InferPostprocessor
Base class for post-processing on inference output.
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:121
nvdsinfer::InferPostprocessor::m_Labels
std::vector< std::vector< std::string > > m_Labels
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:208
NvDsInferLogLevel
NvDsInferLogLevel
Enum for the log levels of NvDsInferContext.
Definition: sources/includes/nvdsinfer.h:262
nvdsinfer::InferPostprocessor::copyBuffersToHostMemory
virtual NvDsInferStatus copyBuffersToHostMemory(NvDsInferBatch &buffer, CudaStream &mainStream)
nvdsinfer::ClassifyPostprocessor::ClassifyPostprocessor
ClassifyPostprocessor(int id, int gpuId=0)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:322
NvDsInferClassificationOutput
Holds information on all attributes classifed by a classifier network for one frame.
Definition: sources/includes/nvdsinfer_context.h:583
NvDsInferNetworkType_Detector
@ NvDsInferNetworkType_Detector
Specifies a detector.
Definition: sources/includes/nvdsinfer_context.h:142
nvdsinfer
Definition: sources/includes/nvdsinfer_logger.h:59
NvDsInferParseDetectionParams
Holds the detection parameters required for parsing objects.
Definition: sources/includes/nvdsinfer_custom_impl.h:184
NvDsInferContextBatchInput
Holds information about one batch to be inferred.
Definition: sources/includes/nvdsinfer_context.h:505
nvdsinfer::DetectPostprocessor::initResource
NvDsInferStatus initResource(const NvDsInferContextInitParams &initParams) override
NvDsInferFormat_RGB
@ NvDsInferFormat_RGB
Specifies 24-bit interleaved R-G-B format.
Definition: sources/includes/nvdsinfer_context.h:166
CudaStream
Helper class for managing Cuda Streams.
Definition: sources/gst-plugins/gst-nvdspreprocess/nvdspreprocess_lib/nvdspreprocess_impl.h:102
nvdsinfer_backend.h
NvDsInferClusterMode
NvDsInferClusterMode
Enum for clustering mode for detectors.
Definition: sources/includes/nvdsinfer_context.h:235
nvdsinfer::InferPostprocessor::setNetworkInfo
void setNetworkInfo(const NvDsInferNetworkInfo &info)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:133
nvdsinfer::NvDsInferContextImpl::NvDsInferContextImpl
NvDsInferContextImpl()
Default constructor.
NVDSINFER_MIN_OUTPUT_BUFFERPOOL_SIZE
#define NVDSINFER_MIN_OUTPUT_BUFFERPOOL_SIZE
Defines the minimum number of sets of output buffers that must be allocated.
Definition: sources/includes/nvdsinfer_context.h:116
nvdsinfer::SegmentPostprocessor::SegmentPostprocessor
SegmentPostprocessor(int id, int gpuId=0)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:351
nvdsinfer::InferPreprocessor::transform
NvDsInferStatus transform(NvDsInferContextBatchInput &batchInput, void *devBuf, CudaStream &mainStream, CudaEvent *waitingEvent)
nvdsinfer::SegmentPostprocessor::initResource
NvDsInferStatus initResource(const NvDsInferContextInitParams &initParams) override
NvDsInferDetectionOutput
Holds information on all objects detected by a detector network in one frame.
Definition: sources/includes/nvdsinfer_context.h:571
NvDsInferNetworkInfo
Holds information about the model network.
Definition: sources/includes/nvdsinfer.h:119
nvdsinfer::InferPostprocessor::m_NetworkInfo
NvDsInferNetworkInfo m_NetworkInfo
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:203
nvdsinfer::OtherPostprocessor::initResource
NvDsInferStatus initResource(const NvDsInferContextInitParams &initParams) override
NvDsInferTensorOrder_kNCHW
@ NvDsInferTensorOrder_kNCHW
Definition: sources/includes/nvdsinfer_context.h:184
nvdsinfer::InferPostprocessor::parseLabelsFile
NvDsInferStatus parseLabelsFile(const std::string &path)
_DS_DEPRECATED_
#define _DS_DEPRECATED_(STR)
Definition: sources/includes/gst-nvdssr.h:34
nvdsinfer::InferPreprocessor::setScaleOffsets
bool setScaleOffsets(float scale, const std::vector< float > &offsets={})
nvdsinfer::InstanceSegmentPostprocessor::InstanceSegmentPostprocessor
InstanceSegmentPostprocessor(int id, int gpuId=0)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:279
NvDsInferNetworkType_InstanceSegmentation
@ NvDsInferNetworkType_InstanceSegmentation
Specifies a instance segmentation network.
Definition: sources/includes/nvdsinfer_context.h:152
_NvDsInferContextInitParams
Holds the initialization parameters required for the NvDsInferContext interface.
Definition: sources/includes/nvdsinfer_context.h:246
nvdsinfer::InferPostprocessor::m_OutputLayerInfo
std::vector< NvDsInferLayerInfo > m_OutputLayerInfo
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:205
nvdsinfer::InferPostprocessor::m_OverwriteOpTensorFilePairs
std::vector< std::pair< std::string, int > > m_OverwriteOpTensorFilePairs
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:200
nvdsinfer::InferPostprocessor::InferPostprocessor
InferPostprocessor(NvDsInferNetworkType type, int id, int gpuId)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:124
nvdsinfer::InferPostprocessor::m_OverwriteOpTensorFiles
std::vector< std::ifstream * > m_OverwriteOpTensorFiles
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:201
nvdsinfer::InferPostprocessor::m_CopyInputToHostBuffers
bool m_CopyInputToHostBuffers
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:195
nvdsinfer::InstanceSegmentPostprocessor::initResource
NvDsInferStatus initResource(const NvDsInferContextInitParams &initParams) override
nvdsinfer::InferPostprocessor::m_NetworkType
NvDsInferNetworkType m_NetworkType
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:187
NvDsInferContextLoggingFunc
void(* NvDsInferContextLoggingFunc)(NvDsInferContextHandle handle, unsigned int uniqueID, NvDsInferLogLevel logLevel, const char *logMessage, void *userCtx)
Type declaration for a logging callback.
Definition: sources/includes/nvdsinfer_context.h:687
NvDsInferNetworkType_Segmentation
@ NvDsInferNetworkType_Segmentation
Specifies a segmentation network.
Definition: sources/includes/nvdsinfer_context.h:148
NvDsInferDetectionParams
Holds detection and bounding box grouping parameters.
Definition: sources/includes/nvdsinfer_context.h:199
nvdsinfer::NvDsInferLoggingFunc
std::function< void(NvDsInferLogLevel, const char *msg)> NvDsInferLoggingFunc
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:53
nvdsinfer::InferPostprocessor::m_DumpOpTensor
bool m_DumpOpTensor
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:197
NvDsInferFrameOutput
Holds the information inferred by the network on one frame.
Definition: sources/includes/nvdsinfer_context.h:619
nvdsinfer::InferPreprocessor::~InferPreprocessor
virtual ~InferPreprocessor()=default
NvDsInferNetworkType
NvDsInferNetworkType
Defines network types.
Definition: sources/includes/nvdsinfer_context.h:138
NvDsInferContextBatchPreprocessedInput
Definition: sources/includes/nvdsinfer_context.h:523
NvDsInferContextBatchOutput
Holds the output for all of the frames in a batch (an array of frame), and related buffer information...
Definition: sources/includes/nvdsinfer_context.h:645
nvdsinfer::InferPostprocessor::m_UniqueID
int m_UniqueID
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:189
nvdsinfer::ClassifyPostprocessor::initResource
NvDsInferStatus initResource(const NvDsInferContextInitParams &initParams) override
NvDsInferNetworkType_Other
@ NvDsInferNetworkType_Other
Specifies other.
Definition: sources/includes/nvdsinfer_context.h:157
nvdsinfer::NvDsInferContextImpl::initialize
NvDsInferStatus initialize(NvDsInferContextInitParams &initParams, void *userCtx, NvDsInferContextLoggingFunc logFunc)
Initializes the Infer engine, allocates layer buffers and other required initialization steps.
nvdsinfer::InferPreprocessor::InferPreprocessor
InferPreprocessor(const NvDsInferNetworkInfo &info, NvDsInferFormat format, const NvDsInferBatchDimsLayerInfo &layerInfo, int id=0)
nvdsinfer::InferPostprocessor::m_DumpOpTensorFiles
std::vector< std::pair< std::string, std::string > > m_DumpOpTensorFiles
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:198
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: sources/includes/nvdsinfer_custom_impl.h:215
nvdsinfer::NvDsInferBatch
Holds information for one batch for processing.
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:58
nvdsinfer::InstanceSegmentPostprocessor::~InstanceSegmentPostprocessor
~InstanceSegmentPostprocessor() override=default
nvdsinfer::OtherPostprocessor::OtherPostprocessor
OtherPostprocessor(int id, int gpuId=0)
Definition: 9.1/sources/libs/nvdsinfer/nvdsinfer_context_impl.h:382
nvdsinfer::InferPreprocessor::setInputOrder
bool setInputOrder(const NvDsInferTensorOrder order)
nvdsinfer::InferPostprocessor::m_LoggingFunc
NvDsInferLoggingFunc m_LoggingFunc
Definition: sources/libs/nvdsinfer/nvdsinfer_context_impl.h:191
nvdsinfer::InferPreprocessor::allocateResource
NvDsInferStatus allocateResource()
ds3d::v2xinfer::format
static std::string format(const char *fmt,...)
Definition: sources/libs/ds3d/inference_custom_lib/ds3d_v2x_infer_custom_preprocess/tensor.hpp:31
NvDsInferStatus
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
Definition: sources/includes/nvdsinfer.h:231
nvdsinfer::InferPreprocessor::syncStream
NvDsInferStatus syncStream()