NVIDIA DeepStream SDK API Reference

9.1 Release
sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_detect.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2022-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 __POST_PROCESSOR_DETECT_HPP__
19 #define __POST_PROCESSOR_DETECT_HPP__
20 
21 #include "post_processor.h"
22 
24  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
25  NvDsInferNetworkInfo const &networkInfo,
26  NvDsPostProcessParseDetectionParams const &detectionParams,
27  std::vector<NvDsPostProcessObjectDetectionInfo> &objectList);
28 
30 
31 public:
32  DetectModelPostProcessor(int id, int gpuId = 0)
34 
36  initResource(NvDsPostProcessContextInitParams& initParams) override;
37  ~DetectModelPostProcessor() override = default;
38  NvDsPostProcessStatus parseEachFrame(const std::vector <NvDsInferLayerInfo>&
39  outputLayers,
40  NvDsPostProcessFrameOutput &result) override;
41  void
42  attachMetadata (NvBufSurface *surf, gint batch_idx,
43  NvDsBatchMeta *batch_meta,
44  NvDsFrameMeta *frame_meta,
45  NvDsObjectMeta *object_meta,
46  NvDsObjectMeta *parent_obj_meta,
47  NvDsPostProcessFrameOutput & detection_output,
49  std::set <gint> & filterOutClassIds,
50  int32_t unique_id,
51  gboolean output_instance_mask,
52  gboolean process_full_frame,
53  float segmentationThreshold,
54  gboolean maintain_aspect_ratio,
55  NvDsRoiMeta *roi_meta,
56  gboolean symmetric_padding) override;
57 
58  void releaseFrameOutput(NvDsPostProcessFrameOutput& frameOutput) override;
59  private:
60  bool parseBoundingBox(std::vector <NvDsInferLayerInfo> const&
61  outputLayersInfo,
62  NvDsInferNetworkInfo const& networkInfo,
63  NvDsPostProcessParseDetectionParams const& detectionParams,
64  std::vector<NvDsPostProcessObjectDetectionInfo>& objectList);
65  std::vector<int> nonMaximumSuppression(
66  std::vector <std::pair<float,int>>& scoreIndex,
67  std::vector<NvDsPostProcessParseObjectInfo> &bbox,
68  float const nmsThreshold);
69 
70  void clusterAndFillDetectionOutputHybrid(NvDsPostProcessDetectionOutput& output);
71  void clusterAndFillDetectionOutputNMS(NvDsPostProcessDetectionOutput& output);
72  void clusterAndFillDetectionOutputDBSCAN(NvDsPostProcessDetectionOutput& output);
73  void fillUnclusteredOutput(NvDsPostProcessDetectionOutput& output);
74  NvDsPostProcessStatus fillDetectionOutput(const std::vector <NvDsInferLayerInfo>& outputLayers,
76  void preClusteringThreshold(NvDsPostProcessParseDetectionParams const &detectionParams,
77  std::vector<NvDsPostProcessObjectDetectionInfo> &objectList);
78  void filterTopKOutputs(int const topK,
79  std::vector<NvDsPostProcessObjectDetectionInfo> &objectList);
80 
81 private:
82  NvDsPostProcessClusterMode m_ClusterMode;
83 
84  uint32_t m_NumDetectedClasses = 0;
85  std::shared_ptr<NvDsInferDBScan> m_DBScanHandle;
86 
87  std::vector <NvDsPostProcessDetectionParams> m_PerClassDetectionParams;
88  NvDsPostProcessParseDetectionParams m_DetectionParams = {0, {}, {}};
89 
90  std::vector <NvDsPostProcessObjectDetectionInfo> m_ObjectList;
91 #ifdef WITH_OPENCV
92  /* Vector of cv::Rect vectors for each class. */
93  std::vector<std::vector<cv::Rect>> m_PerClassCvRectList;
94 #endif
95  /* Vector of NvDsPostProcessObjectDetectionInfo vectors for each class. */
96  std::vector<std::vector<NvDsPostProcessObjectDetectionInfo>> m_PerClassObjectList;
97 
98  NvDsPostProcessParseCustomFunc m_CustomBBoxParseFunc = nullptr;
99  bool m_PreprocessorSupport = FALSE;
100 
101 };
102 
103 
104 #endif
DetectModelPostProcessor::DetectModelPostProcessor
DetectModelPostProcessor(int id, int gpuId=0)
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_detect.h:32
NvDsPostProcessDetectionParams
Holds detection and bounding box grouping parameters.
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_struct.h:212
DetectModelPostProcessor::releaseFrameOutput
void releaseFrameOutput(NvDsPostProcessFrameOutput &frameOutput) override
ModelPostProcessor
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor.h:51
post_processor.h
NvBufSurface
Holds information about batched buffers.
Definition: sources/includes/nvbufsurface.h:597
NvDsPostProcessClusterMode
NvDsPostProcessClusterMode
Enum for clustering mode for detectors.
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_struct.h:163
DetectModelPostProcessor::attachMetadata
void attachMetadata(NvBufSurface *surf, gint batch_idx, NvDsBatchMeta *batch_meta, NvDsFrameMeta *frame_meta, NvDsObjectMeta *object_meta, NvDsObjectMeta *parent_obj_meta, NvDsPostProcessFrameOutput &detection_output, NvDsPostProcessDetectionParams *all_params, std::set< gint > &filterOutClassIds, int32_t unique_id, gboolean output_instance_mask, gboolean process_full_frame, float segmentationThreshold, gboolean maintain_aspect_ratio, NvDsRoiMeta *roi_meta, gboolean symmetric_padding) override
NvDsPostProcessDetectionOutput
Holds information on all objects detected by a detector network in one frame.
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_struct.h:433
DetectModelPostProcessor
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_detect.h:29
NvDsPostProcessStatus
NvDsPostProcessStatus
Enum for the status codes returned by NvDsPostProcessAlgorithm.
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_struct.h:78
DetectModelPostProcessor::~DetectModelPostProcessor
~DetectModelPostProcessor() override=default
DetectModelPostProcessor::parseEachFrame
NvDsPostProcessStatus parseEachFrame(const std::vector< NvDsInferLayerInfo > &outputLayers, NvDsPostProcessFrameOutput &result) override
NvDsInferNetworkInfo
Holds information about the model network.
Definition: sources/includes/nvdsinfer.h:119
_NvDsBatchMeta
Holds information about a formed batch containing frames from different sources.
Definition: sources/includes/nvdsmeta.h:262
NvDsPostProcessNetworkType_Detector
@ NvDsPostProcessNetworkType_Detector
Specifies a detector.
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_struct.h:189
_NvDsPostProcessContextInitParams
Holds the initialization parameters required for the NvDsPostProcessContext interface.
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_struct.h:256
NvDsPostProcessFrameOutput
Holds the information inferred by the network on one frame.
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_struct.h:502
DetectModelPostProcessor::initResource
NvDsPostProcessStatus initResource(NvDsPostProcessContextInitParams &initParams) override
NvDsRoiMeta
Holds Information about ROI Metadata.
Definition: sources/includes/nvds_roi_meta.h:95
_NvDsFrameMeta
Holds metadata for a frame in a batch.
Definition: sources/includes/nvdsmeta.h:306
NvDsPostProcessParseCustomFunc
bool(* NvDsPostProcessParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, NvDsPostProcessParseDetectionParams const &detectionParams, std::vector< NvDsPostProcessObjectDetectionInfo > &objectList)
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_detect.h:23
NvDsPostProcessParseDetectionParams
Holds the detection parameters required for parsing objects.
Definition: sources/gst-plugins/gst-nvdspostprocess/postprocesslib_impl/post_processor_struct.h:561
_NvDsObjectMeta
Holds metadata for an object in the frame.
Definition: sources/includes/nvdsmeta.h:365