NVIDIA DeepStream SDK API Reference

9.2 Release
sources/gst-plugins/gst-nvdsvideotemplate/ds-sparse4d/postprocess/display_bbox3d.h File Reference

Go to the source code of this file.

Data Structures

struct  ClassThreshold
 Structure to hold class label and its confidence threshold. More...
 

Functions

std::vector< ClassThreshold > fetch_class_labels_with_thresholds (const std::string &labels_file, PrettyLogger *logger)
 Fetch class labels and thresholds from a labels file. More...
 
std::vector< std::string > extract_class_labels (const std::vector< ClassThreshold > &class_thresholds)
 Extract class label strings from ClassThreshold vector. More...
 
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. More...
 
void clamp_point (float *x, float *y, int img_width, int img_height)
 Clamps a point to stay within image boundaries. More...
 
void calculate_centroid (const float *points, float *centroid)
 Calculates the centroid of a 3D bounding box from its 2D projection. More...
 
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. More...
 
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. More...
 
bool count_visible_corners (const float *points, int num_corners, int img_width, int img_height)
 Counts visible corners of a 3D bounding box. More...
 
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. More...
 

Function Documentation

◆ 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.

Parameters
batch_metaDeepStream batch metadata
frame_metaDeepStream frame metadata
bbox2dTensor containing 2D bounding boxes [N, 4] where 4 = [x, y, w, h]
boxes_3dTensor containing 3D bounding box information
labels_3dTensor containing class labels
instance_idsTensor containing instance IDs for tracking
scores_3dTensor containing confidence scores
class_labelsVector of class label strings
bbox_color_modeColor mode: "class_id" for class-based or "instance_id" for instance-based colors
display_2d_bboxWhether to display 2D bounding boxes on frames
loggerLogger for debug and warning messages

◆ 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.

This function processes 3D bounding box projections and attaches them to the DeepStream display metadata for visualization on the frame.

Parameters
batch_metaDeepStream batch metadata
frame_metaDeepStream frame metadata
camera_framesTensor containing projected 3D bbox coordinates
boxes_3dTensor containing 3D bounding box coordinates
labels_3dTensor containing label indices
instance_idsTensor containing instance IDs
scores_3dTensor containing confidence scores
img_widthWidth of the image
img_heightHeight of the image
class_labelsVector of class label strings
bbox_color_modeColor mode for bounding boxes (class_id or instance_id)
display_class_labelsWhether to display class labels
display_instance_idsWhether to display instance IDs
display_class_scoreWhether to display class confidence score
loggerLogger for debug and warning messages

◆ calculate_centroid()

void calculate_centroid ( const float *  points,
float *  centroid 
)

Calculates the centroid of a 3D bounding box from its 2D projection.

Parameters
pointsArray of 2D points
centroidArray to store centroid coordinates

◆ clamp_point()

void clamp_point ( float *  x,
float *  y,
int  img_width,
int  img_height 
)

Clamps a point to stay within image boundaries.

Parameters
xX-coordinate to clamp
yY-coordinate to clamp
img_widthImage width
img_heightImage height

◆ 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.

Parameters
pointsArray of 2D points
num_cornersNumber of corners
img_widthImage width
img_heightImage height
Returns
true if half or more corners are visible

◆ extract_class_labels()

std::vector<std::string> extract_class_labels ( const std::vector< ClassThreshold > &  class_thresholds)

Extract class label strings from ClassThreshold vector.

Parameters
class_thresholdsVector of ClassThreshold structures
Returns
Vector of class label strings only

◆ 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.

This function reads class labels and their confidence thresholds from a file where each entry is in format: class_name:threshold; Example: Person:0.85;Vehicle:0.90;

Parameters
labels_filePath to the file containing class labels and thresholds
loggerLogger for debug and warning messages
Returns
Vector of ClassThreshold structures containing labels and thresholds

◆ 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.

Parameters
instance_idInstance ID
redOutput red component [0-1]
greenOutput green component [0-1]
blueOutput blue component [0-1]

◆ 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.

Parameters
labelClass label string
redOutput red component [0-1]
greenOutput green component [0-1]
blueOutput blue component [0-1]
num_classesNumber of unique classes