NVIDIA DeepStream SDK API Reference

7.0 Release
post_processor_instance_segment.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2022 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) override;
73 
74  void releaseFrameOutput(NvDsPostProcessFrameOutput& frameOutput) override;
75  private:
76 
77 
78  void fillUnclusteredOutput(NvDsPostProcessDetectionOutput& output);
79  NvDsPostProcessStatus fillDetectionOutput(const std::vector <NvDsInferLayerInfo>& outputLayers,
81  void preClusteringThreshold(NvDsPostProcessParseDetectionParams const &detectionParams,
82  std::vector<NvDsPostProcessInstanceMaskInfo> &objectList);
83  void filterTopKOutputs(int const topK,
84  std::vector<NvDsPostProcessInstanceMaskInfo> &objectList);
85 
86 private:
87  NvDsPostProcessClusterMode m_ClusterMode;
88 
89  uint32_t m_NumDetectedClasses = 0;
90 
91  std::vector <NvDsPostProcessDetectionParams> m_PerClassDetectionParams;
92  NvDsPostProcessParseDetectionParams m_DetectionParams = {0, {}, {}};
93 
94  std::vector <NvDsPostProcessInstanceMaskInfo> m_InstanceMaskList;
95  /* Vector of NvDsPostProcessInstanceMaskInfo vectors for each class. */
96  std::vector<std::vector<NvDsPostProcessInstanceMaskInfo>> m_PerClassInstanceMaskList;
97 
98  NvDsPostProcessInstanceMaskParseCustomFunc m_CustomParseFunc= nullptr;
99 
100 };
101 
102 
103 #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:216
ModelPostProcessor
Definition: post_processor.h:57
NvBufSurface
Holds information about batched buffers.
Definition: nvbufsurface.h:509
post_processor.h
NvDsPostProcessDetectionOutput
Holds information on all objects detected by a detector network in one frame.
Definition: post_processor_struct.h:435
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:110
_NvDsBatchMeta
Holds information about a formed batch containing frames from different sources.
Definition: nvdsmeta.h:241
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:260
NvDsPostProcessFrameOutput
Holds the information inferred by the network on one frame.
Definition: post_processor_struct.h:483
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::InstanceSegmentModelPostProcessor
InstanceSegmentModelPostProcessor(int id, int gpuId=0)
Definition: post_processor_instance_segment.h:50
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) override
InstanceSegmentModelPostProcessor::releaseFrameOutput
void releaseFrameOutput(NvDsPostProcessFrameOutput &frameOutput) override
_NvDsFrameMeta
Holds metadata for a frame in a batch.
Definition: nvdsmeta.h:285
NvDsPostProcessParseDetectionParams
Holds the detection parameters required for parsing objects.
Definition: post_processor_struct.h:539
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:343