NVIDIA DeepStream SDK API Reference

7.1 Release
post_processor_instance_segment.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef __POST_PROCESSOR_INSTANCE_SEGMENT_HPP__
25 #define __POST_PROCESSOR_INSTANCE_SEGMENT_HPP__
26 
27 #include "post_processor.h"
28 
41  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
42  NvDsInferNetworkInfo const &networkInfo,
43  NvDsPostProcessParseDetectionParams const &detectionParams,
44  std::vector<NvDsPostProcessInstanceMaskInfo> &objectList);
45 
46 
48 
49 public:
50  InstanceSegmentModelPostProcessor(int id, int gpuId = 0)
52 
54  initResource(NvDsPostProcessContextInitParams& initParams) override;
55  ~InstanceSegmentModelPostProcessor() override = default;
56  NvDsPostProcessStatus parseEachFrame(const std::vector <NvDsInferLayerInfo>&
57  outputLayers,
58  NvDsPostProcessFrameOutput &result) override;
59  void
60  attachMetadata (NvBufSurface *surf, gint batch_idx,
61  NvDsBatchMeta *batch_meta,
62  NvDsFrameMeta *frame_meta,
63  NvDsObjectMeta *object_meta,
64  NvDsObjectMeta *parent_obj_meta,
65  NvDsPostProcessFrameOutput & detection_output,
67  std::set <gint> & filterOutClassIds,
68  int32_t unique_id,
69  gboolean output_instance_mask,
70  gboolean process_full_frame,
71  float segmentationThreshold,
72  gboolean maintain_aspect_ratio,
73  NvDsRoiMeta *roi_meta,
74  gboolean symmetric_padding) override;
75 
76  void releaseFrameOutput(NvDsPostProcessFrameOutput& frameOutput) override;
77  private:
78 
79 
80  void fillUnclusteredOutput(NvDsPostProcessDetectionOutput& output);
81  NvDsPostProcessStatus fillDetectionOutput(const std::vector <NvDsInferLayerInfo>& outputLayers,
83  void preClusteringThreshold(NvDsPostProcessParseDetectionParams const &detectionParams,
84  std::vector<NvDsPostProcessInstanceMaskInfo> &objectList);
85  void filterTopKOutputs(int const topK,
86  std::vector<NvDsPostProcessInstanceMaskInfo> &objectList);
87 
88 private:
89  NvDsPostProcessClusterMode m_ClusterMode;
90 
91  uint32_t m_NumDetectedClasses = 0;
92 
93  std::vector <NvDsPostProcessDetectionParams> m_PerClassDetectionParams;
94  NvDsPostProcessParseDetectionParams m_DetectionParams = {0, {}, {}};
95 
96  std::vector <NvDsPostProcessInstanceMaskInfo> m_InstanceMaskList;
97  /* Vector of NvDsPostProcessInstanceMaskInfo vectors for each class. */
98  std::vector<std::vector<NvDsPostProcessInstanceMaskInfo>> m_PerClassInstanceMaskList;
99 
100  NvDsPostProcessInstanceMaskParseCustomFunc m_CustomParseFunc= nullptr;
101 
102 };
103 
104 
105 #endif
InstanceSegmentModelPostProcessor::parseEachFrame
NvDsPostProcessStatus parseEachFrame(const std::vector< NvDsInferLayerInfo > &outputLayers, NvDsPostProcessFrameOutput &result) override
InstanceSegmentModelPostProcessor::initResource
NvDsPostProcessStatus initResource(NvDsPostProcessContextInitParams &initParams) override
InstanceSegmentModelPostProcessor
Definition: post_processor_instance_segment.h:47
NvDsPostProcessDetectionParams
Holds detection and bounding box grouping parameters.
Definition: post_processor_struct.h:218
ModelPostProcessor
Definition: post_processor.h:57
NvBufSurface
Holds information about batched buffers.
Definition: nvbufsurface.h:520
post_processor.h
NvDsPostProcessDetectionOutput
Holds information on all objects detected by a detector network in one frame.
Definition: post_processor_struct.h:439
NvDsPostProcessStatus
NvDsPostProcessStatus
Enum for the status codes returned by NvDsPostProcessAlgorithm.
Definition: post_processor_struct.h:84
InstanceSegmentModelPostProcessor::~InstanceSegmentModelPostProcessor
~InstanceSegmentModelPostProcessor() override=default
NvDsInferNetworkInfo
Holds information about the model network.
Definition: nvdsinfer.h:112
_NvDsBatchMeta
Holds information about a formed batch containing frames from different sources.
Definition: nvdsmeta.h:242
NvDsPostProcessClusterMode
NvDsPostProcessClusterMode
Enum for clustering mode for detectors.
Definition: post_processor_struct.h:169
_NvDsPostProcessContextInitParams
Holds the initialization parameters required for the NvDsPostProcessContext interface.
Definition: post_processor_struct.h:262
NvDsPostProcessFrameOutput
Holds the information inferred by the network on one frame.
Definition: post_processor_struct.h:508
NvDsPostProcessInstanceMaskParseCustomFunc
bool(* NvDsPostProcessInstanceMaskParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, NvDsPostProcessParseDetectionParams const &detectionParams, std::vector< NvDsPostProcessInstanceMaskInfo > &objectList)
Type definition for the custom bounding box and instance mask parsing function.
Definition: post_processor_instance_segment.h:40
InstanceSegmentModelPostProcessor::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
InstanceSegmentModelPostProcessor::InstanceSegmentModelPostProcessor
InstanceSegmentModelPostProcessor(int id, int gpuId=0)
Definition: post_processor_instance_segment.h:50
NvDsRoiMeta
Holds Information about ROI Metadata.
Definition: nvds_roi_meta.h:86
InstanceSegmentModelPostProcessor::releaseFrameOutput
void releaseFrameOutput(NvDsPostProcessFrameOutput &frameOutput) override
_NvDsFrameMeta
Holds metadata for a frame in a batch.
Definition: nvdsmeta.h:286
NvDsPostProcessParseDetectionParams
Holds the detection parameters required for parsing objects.
Definition: post_processor_struct.h:567
NvDsPostProcessNetworkType_InstanceSegmentation
@ NvDsPostProcessNetworkType_InstanceSegmentation
Specifies a instance segmentation network.
Definition: post_processor_struct.h:205
_NvDsObjectMeta
Holds metadata for an object in the frame.
Definition: nvdsmeta.h:344