NVIDIA DeepStream SDK API Reference

9.2 Release
sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/display_bbox3d.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 DISPLAY_BBOX3D_H
19 #define DISPLAY_BBOX3D_H
20 
21 #include <string>
22 #include <vector>
23 #include <torch/torch.h>
24 #include "gstnvdsmeta.h"
25 // Forward declaration to avoid circular dependency
26 struct DecodedResult;
27 
28 #include "../utils/log_utils.h"
29 
34  std::string label;
35  float threshold;
36 };
37 
49 std::vector<ClassThreshold> fetch_class_labels_with_thresholds(
50  const std::string& labels_file,
52 );
53 
60 std::vector<std::string> extract_class_labels(
61  const std::vector<ClassThreshold>& class_thresholds
62 );
63 
87  NvDsBatchMeta* batch_meta,
88  NvDsFrameMeta* frame_meta,
89  const torch::Tensor& camera_frames,
90  const torch::Tensor& boxes_3d,
91  const torch::Tensor& labels_3d,
92  const torch::Tensor& instance_ids,
93  const torch::Tensor& scores_3d,
94  int img_width,
95  int img_height,
96  const std::vector<std::string>& class_labels,
97  const std::string& bbox_color_mode,
98  const bool& display_class_labels,
99  const bool& display_instance_ids,
100  const bool& display_class_score,
102 );
103 
112 void clamp_point(float* x, float* y, int img_width, int img_height);
113 
120 void calculate_centroid(const float* points, float* centroid);
121 
131 void get_color_from_label(const std::string& label, float* red, float* green, float* blue, int num_classes);
132 
141 void get_color_from_instance_id(int64_t instance_id, float* red, float* green, float* blue);
142 
152 bool count_visible_corners(const float* points, int num_corners, int img_width, int img_height);
153 
170  NvDsBatchMeta* batch_meta,
171  NvDsFrameMeta* frame_meta,
172  const torch::Tensor& bbox2d,
173  const torch::Tensor& boxes_3d,
174  const torch::Tensor& labels_3d,
175  const torch::Tensor& instance_ids,
176  const torch::Tensor& scores_3d,
177  const std::vector<std::string>& class_labels,
178  const std::string& bbox_color_mode,
179  const bool& display_2d_bbox,
181 );
182 
183 #endif // DISPLAY_BBOX3D_H
get_color_from_label
void get_color_from_label(const std::string &label, float *red, float *green, float *blue, int num_classes)
Generates a consistent color based on a class label.
calculate_centroid
void calculate_centroid(const float *points, float *centroid)
Calculates the centroid of a 3D bounding box from its 2D projection.
extract_class_labels
std::vector< std::string > extract_class_labels(const std::vector< ClassThreshold > &class_thresholds)
Extract class label strings from ClassThreshold vector.
PrettyLogger
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/utils/log_utils.h:57
count_visible_corners
bool count_visible_corners(const float *points, int num_corners, int img_width, int img_height)
Counts visible corners of a 3D bounding box.
attach_bbox3d_to_display
void attach_bbox3d_to_display(NvDsBatchMeta *batch_meta, NvDsFrameMeta *frame_meta, const torch::Tensor &camera_frames, const torch::Tensor &boxes_3d, const torch::Tensor &labels_3d, const torch::Tensor &instance_ids, const torch::Tensor &scores_3d, int img_width, int img_height, const std::vector< std::string > &class_labels, const std::string &bbox_color_mode, const bool &display_class_labels, const bool &display_instance_ids, const bool &display_class_score, PrettyLogger *logger)
Attach 3D bounding boxes to display metadata for visualization.
ClassThreshold
Structure to hold class label and its confidence threshold.
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/display_bbox3d.h:33
_NvDsBatchMeta
Holds information about a formed batch containing frames from different sources.
Definition: includes/nvdsmeta.h:264
DecodedResult
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/decoder.h:30
attach_bbox2d_to_objectmeta
void attach_bbox2d_to_objectmeta(NvDsBatchMeta *batch_meta, NvDsFrameMeta *frame_meta, const torch::Tensor &bbox2d, const torch::Tensor &boxes_3d, const torch::Tensor &labels_3d, const torch::Tensor &instance_ids, const torch::Tensor &scores_3d, const std::vector< std::string > &class_labels, const std::string &bbox_color_mode, const bool &display_2d_bbox, PrettyLogger *logger)
Attach 2D bounding boxes as NvDsObjectMeta to frame metadata.
get_color_from_instance_id
void get_color_from_instance_id(int64_t instance_id, float *red, float *green, float *blue)
Generates a color based on instance ID for tracking visualization.
logger
Logger logger
fetch_class_labels_with_thresholds
std::vector< ClassThreshold > fetch_class_labels_with_thresholds(const std::string &labels_file, PrettyLogger *logger)
Fetch class labels and thresholds from a labels file.
_NvDsFrameMeta
Holds metadata for a frame in a batch.
Definition: includes/nvdsmeta.h:308
ClassThreshold::label
std::string label
Class label name.
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/display_bbox3d.h:34
ClassThreshold::threshold
float threshold
Confidence threshold for this class.
Definition: sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/display_bbox3d.h:35
clamp_point
void clamp_point(float *x, float *y, int img_width, int img_height)
Clamps a point to stay within image boundaries.