NVIDIA DeepStream SDK API Reference

9.2 Release
sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2025-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 DECODER_H
19 #define DECODER_H
20 
21 #include <torch/torch.h>
22 
23 #include "../utils/log_utils.h"
24 
25 // Forward declaration to avoid circular dependency
26 struct ClassThreshold;
27 #include "../utils/tensor.h"
28 
29 // Structure to hold decoded result data
30 struct DecodedResult {
31  torch::Tensor boxes_3d;
32  torch::Tensor scores_3d;
33  torch::Tensor labels_3d;
34  torch::Tensor cls_scores;
35  torch::Tensor instance_ids;
36  torch::Tensor instance_feats;
37 };
38 
40 public:
52  int num_output = 300,
53  float score_threshold = 0.0f,
54  bool sorted = true,
55  torch::Tensor group_origin = torch::Tensor(),
56  int gpu_id = 0,
57  PrettyLogger* logger = nullptr);
58 
66  torch::Tensor decode_box(torch::Tensor& box, bool dummy_rotation = true);
67 
79  std::vector<DecodedResult> decode(
80  const std::vector<torch::Tensor>& cls_scores,
81  const std::vector<torch::Tensor>& box_preds,
82  const torch::Tensor& instance_id = torch::Tensor(),
83  const torch::Tensor& instance_feature = torch::Tensor(),
84  const std::vector<torch::Tensor>& quality = std::vector<torch::Tensor>(),
85  int output_idx = -1);
86 
87 private:
88  int num_output;
89  float score_threshold;
90  bool sorted;
91  torch::Tensor group_origin;
92  int gpu_id;
93  PrettyLogger* logger;
94 };
95 
103 void filter_results(const std::vector<DecodedResult>& results,
104  const std::vector<ClassThreshold>& class_thresholds,
106 
107 #endif // DECODER_H
PrettyLogger
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/utils/log_utils.h:57
DecodedResult::labels_3d
torch::Tensor labels_3d
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:33
DecodedResult::instance_feats
torch::Tensor instance_feats
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:36
SparseBox3DDecoder::SparseBox3DDecoder
SparseBox3DDecoder(int num_output=300, float score_threshold=0.0f, bool sorted=true, torch::Tensor group_origin=torch::Tensor(), int gpu_id=0, PrettyLogger *logger=nullptr)
Constructor for SparseBox3DDecoder.
DecodedResult::scores_3d
torch::Tensor scores_3d
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:32
ClassThreshold
Structure to hold class label and its confidence threshold.
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/display_bbox3d.h:33
DecodedResult
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:30
SparseBox3DDecoder::decode
std::vector< DecodedResult > decode(const std::vector< torch::Tensor > &cls_scores, const std::vector< torch::Tensor > &box_preds, const torch::Tensor &instance_id=torch::Tensor(), const torch::Tensor &instance_feature=torch::Tensor(), const std::vector< torch::Tensor > &quality=std::vector< torch::Tensor >(), int output_idx=-1)
Decodes model predictions into final detection outputs.
SparseBox3DDecoder::decode_box
torch::Tensor decode_box(torch::Tensor &box, bool dummy_rotation=true)
Decodes box parameters from network output format to actual box dimensions.
quality
int quality
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jpeglib.h:936
DecodedResult::cls_scores
torch::Tensor cls_scores
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:34
logger
Logger logger
DecodedResult::boxes_3d
torch::Tensor boxes_3d
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:31
SparseBox3DDecoder
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:39
filter_results
void filter_results(const std::vector< DecodedResult > &results, const std::vector< ClassThreshold > &class_thresholds, PrettyLogger *logger)
Filters results based on per-class confidence thresholds.
DecodedResult::instance_ids
torch::Tensor instance_ids
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:35