NVIDIA DeepStream SDK API Reference

6.4 Release
post_processor_classify.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_CLASSIFY_HPP__
25 #define __POST_PROCESSOR_CLASSIFY_HPP__
26 
27 #include "post_processor.h"
28 
29 
31  std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
32  NvDsInferNetworkInfo const &networkInfo,
33  float classifierThreshold,
34  std::vector<NvDsPostProcessAttribute> &attrList,
35  std::string &descString);
36 
38 
39 public:
40  ClassifyModelPostProcessor(int id, int gpuId = 0)
42 
43  ~ClassifyModelPostProcessor() override = default;
44 
46  initResource(NvDsPostProcessContextInitParams& initParams) override;
47 
48  NvDsPostProcessStatus parseEachFrame(const std::vector <NvDsInferLayerInfo>&
49  outputLayers,
50  NvDsPostProcessFrameOutput &result) override;
51 
52  void
53  attachMetadata (NvBufSurface *surf, gint batch_idx,
54  NvDsBatchMeta *batch_meta,
55  NvDsFrameMeta *frame_meta,
56  NvDsObjectMeta *object_meta,
57  NvDsObjectMeta *parent_obj_meta,
58  NvDsPostProcessFrameOutput & detection_output,
60  std::set <gint> & filterOutClassIds,
61  int32_t unique_id,
62  gboolean output_instance_mask,
63  gboolean process_full_frame,
64  float segmentationThreshold,
65  gboolean maintain_aspect_ratio) override;
66 
67 
68  void
70  NvDsPostProcessObjectInfo &new_result);
71 
72  void releaseFrameOutput(NvDsPostProcessFrameOutput& frameOutput) override;
73 
74 private:
75  NvDsPostProcessStatus fillClassificationOutput(
76  const std::vector<NvDsInferLayerInfo>& outputLayers,
78  bool parseAttributesFromSoftmaxLayers(
79  std::vector<NvDsInferLayerInfo> const& outputLayersInfo,
80  NvDsInferNetworkInfo const& networkInfo, float classifierThreshold,
81  std::vector<NvDsPostProcessAttribute>& attrList, std::string& attrString);
82 
83  NvDsPostProcessObjectInfo m_ObjectHistory;
84  float m_ClassifierThreshold = 0.51;
85  const gchar *m_ClassifierType;
86  uint32_t m_NumClasses = 0;
87  NvDsPostProcessClassiferParseCustomFunc m_CustomClassifierParseFunc = nullptr;
88 };
89 
90 #endif
ClassifyModelPostProcessor::parseEachFrame
NvDsPostProcessStatus parseEachFrame(const std::vector< NvDsInferLayerInfo > &outputLayers, NvDsPostProcessFrameOutput &result) override
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:503
post_processor.h
NvDsPostProcessObjectInfo
Holds the cached information of an object.
Definition: post_processor_struct.h:558
NvDsPostProcessClassiferParseCustomFunc
bool(* NvDsPostProcessClassiferParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, float classifierThreshold, std::vector< NvDsPostProcessAttribute > &attrList, std::string &descString)
Definition: post_processor_classify.h:30
NvDsPostProcessStatus
NvDsPostProcessStatus
Enum for the status codes returned by NvDsPostProcessAlgorithm.
Definition: post_processor_struct.h:84
ClassifyModelPostProcessor::initResource
NvDsPostProcessStatus initResource(NvDsPostProcessContextInitParams &initParams) override
ClassifyModelPostProcessor
Definition: post_processor_classify.h:37
NvDsInferNetworkInfo
Holds information about the model network.
Definition: nvdsinfer.h:110
ClassifyModelPostProcessor::~ClassifyModelPostProcessor
~ClassifyModelPostProcessor() override=default
_NvDsBatchMeta
Holds information about a formed batch containing frames from different sources.
Definition: nvdsmeta.h:240
_NvDsPostProcessContextInitParams
Holds the initialization parameters required for the NvDsPostProcessContext interface.
Definition: post_processor_struct.h:260
ClassifyModelPostProcessor::ClassifyModelPostProcessor
ClassifyModelPostProcessor(int id, int gpuId=0)
Definition: post_processor_classify.h:40
NvDsPostProcessFrameOutput
Holds the information inferred by the network on one frame.
Definition: post_processor_struct.h:483
ClassifyModelPostProcessor::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
_NvDsPostProcessObjectHistory
Holds the inference information/history for one object based on it's tracking id.
Definition: post_processor_struct.h:579
NvDsPostProcessNetworkType_Classifier
@ NvDsPostProcessNetworkType_Classifier
Specifies a classifier.
Definition: post_processor_struct.h:198
_NvDsFrameMeta
Holds metadata for a frame in a batch.
Definition: nvdsmeta.h:284
ClassifyModelPostProcessor::mergeClassificationOutput
void mergeClassificationOutput(NvDsPostProcessObjectHistory &history, NvDsPostProcessObjectInfo &new_result)
NvDsPostProcessClassificationOutput
Holds information on all attributes classifed by a classifier network for one frame.
Definition: post_processor_struct.h:447
ClassifyModelPostProcessor::releaseFrameOutput
void releaseFrameOutput(NvDsPostProcessFrameOutput &frameOutput) override
_NvDsObjectMeta
Holds metadata for an object in the frame.
Definition: nvdsmeta.h:342