OpenCV  3.4.18
Open Source Computer Vision
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
cv::dnn_objdetect::InferBbox Class Reference

A class to post process model predictions. More...

#include <opencv2/core_detect.hpp>

Public Member Functions

 InferBbox (Mat _delta_bbox, Mat _class_scores, Mat _conf_scores)
 Default constructer. More...
 
void filter (double thresh=0.8)
 Filters the bounding boxes. More...
 

Public Attributes

std::vector< objectdetections
 Vector which holds the final detections of the model. More...
 

Protected Member Functions

void assert_predictions (std::vector< std::vector< double > > *min_max_boxes)
 Ensures that the bounding box values are within image boundaries. More...
 
void filter_top_n (std::vector< std::vector< double > > *probs, std::vector< std::vector< double > > *boxes, std::vector< std::vector< double > > &top_n_boxes, std::vector< size_t > &top_n_idxs, std::vector< double > &top_n_probs)
 Filter top n predictions. More...
 
void final_probability_dist (std::vector< std::vector< double > > *final_probs)
 Computes final probability values of each bounding box. More...
 
void intersection_over_union (std::vector< std::vector< double > > *boxes, std::vector< double > *base_box, std::vector< double > *iou)
 Computes intersection over union of bounding boxes. More...
 
void nms_wrapper (std::vector< std::vector< double > > &top_n_boxes, std::vector< size_t > &top_n_idxs, std::vector< double > &top_n_probs)
 Wrapper to apply Non-Maximal Supression. More...
 
std::vector< bool > non_maximal_suppression (std::vector< std::vector< double > > *boxes, std::vector< double > *probs)
 Applies Non-Maximal Supression. More...
 
void transform_bboxes (std::vector< std::vector< double > > *bboxes)
 Transform relative coordinates from ConvDet to bounding box coordinates. More...
 
void transform_bboxes_inv (std::vector< std::vector< double > > *pre, std::vector< std::vector< double > > *post)
 Transform bounding boxes from [x, y, h, w] to [xmin, ymin, xmax, ymax]. More...
 

Static Protected Member Functions

static bool comparator (std::pair< double, size_t > l1, std::pair< double, size_t > l2)
 

Detailed Description

A class to post process model predictions.

Constructor & Destructor Documentation

◆ InferBbox()

cv::dnn_objdetect::InferBbox::InferBbox ( Mat  _delta_bbox,
Mat  _class_scores,
Mat  _conf_scores 
)

Default constructer.

Parameters
_delta_bboxBlob containing relative coordinates of bounding boxes
_class_scoresBlob containing the probability values of each class
_conf_scoresBlob containing the confidence scores

Member Function Documentation

◆ assert_predictions()

void cv::dnn_objdetect::InferBbox::assert_predictions ( std::vector< std::vector< double > > *  min_max_boxes)
protected

Ensures that the bounding box values are within image boundaries.

Parameters
min_max_boxesVector containing bounding boxes of the form [xmin, ymin, xmax, ymax]

◆ comparator()

static bool cv::dnn_objdetect::InferBbox::comparator ( std::pair< double, size_t >  l1,
std::pair< double, size_t >  l2 
)
inlinestaticprotected

◆ filter()

void cv::dnn_objdetect::InferBbox::filter ( double  thresh = 0.8)

Filters the bounding boxes.

◆ filter_top_n()

void cv::dnn_objdetect::InferBbox::filter_top_n ( std::vector< std::vector< double > > *  probs,
std::vector< std::vector< double > > *  boxes,
std::vector< std::vector< double > > &  top_n_boxes,
std::vector< size_t > &  top_n_idxs,
std::vector< double > &  top_n_probs 
)
protected

Filter top n predictions.

Parameters
probsFinal probability values of bounding boxes
boxesPredicted bounding box co-ordinates
top_n_boxesContains bounding box co-ordinates of top n boxes
top_n_idxsContaines class indices of top n bounding boxes
top_n_probsContains probability values of top n bounding boxes

◆ final_probability_dist()

void cv::dnn_objdetect::InferBbox::final_probability_dist ( std::vector< std::vector< double > > *  final_probs)
protected

Computes final probability values of each bounding box.

Parameters
final_probsVector to hold the probability values

◆ intersection_over_union()

void cv::dnn_objdetect::InferBbox::intersection_over_union ( std::vector< std::vector< double > > *  boxes,
std::vector< double > *  base_box,
std::vector< double > *  iou 
)
protected

Computes intersection over union of bounding boxes.

Parameters
boxesVector of bounding box co-ordinates
base_boxBase box wrt which IOU is calculated
iouVector to store IOU values

◆ nms_wrapper()

void cv::dnn_objdetect::InferBbox::nms_wrapper ( std::vector< std::vector< double > > &  top_n_boxes,
std::vector< size_t > &  top_n_idxs,
std::vector< double > &  top_n_probs 
)
protected

Wrapper to apply Non-Maximal Supression.

Parameters
top_n_boxesContains bounding box co-ordinates of top n boxes
top_n_idxsContaines class indices of top n bounding boxes
top_n_probsContains probability values of top n bounding boxes

◆ non_maximal_suppression()

std::vector<bool> cv::dnn_objdetect::InferBbox::non_maximal_suppression ( std::vector< std::vector< double > > *  boxes,
std::vector< double > *  probs 
)
protected

Applies Non-Maximal Supression.

Parameters
boxesBounding box co-ordinates belonging to one class
probsProbability values of boxes belonging to one class

◆ transform_bboxes()

void cv::dnn_objdetect::InferBbox::transform_bboxes ( std::vector< std::vector< double > > *  bboxes)
protected

Transform relative coordinates from ConvDet to bounding box coordinates.

Parameters
bboxesVector to hold the predicted bounding boxes

◆ transform_bboxes_inv()

void cv::dnn_objdetect::InferBbox::transform_bboxes_inv ( std::vector< std::vector< double > > *  pre,
std::vector< std::vector< double > > *  post 
)
protected

Transform bounding boxes from [x, y, h, w] to [xmin, ymin, xmax, ymax].

Parameters
preVector conatining initial co-ordinates
postVector containing the transformed co-ordinates

Member Data Documentation

◆ detections

std::vector<object> cv::dnn_objdetect::InferBbox::detections

Vector which holds the final detections of the model.


The documentation for this class was generated from the following file: