OpenCV 4.5.3(日本語機械翻訳)
core_detect.hpp
1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 #ifndef _OPENCV_DNN_OBJDETECT_CORE_DETECT_HPP_
5 #define _OPENCV_DNN_OBJDETECT_CORE_DETECT_HPP_
6
7 #include <vector>
8 #include <memory>
9
10 #include <opencv2/imgproc.hpp>
11
15 namespace cv
16{
17 namespace dnn_objdetect
18{
19
22
25 typedef struct
26 {
27 int xmin, xmax;
28 int ymin, ymax;
29 size_t class_idx;
30 std::string label_name;
31 double class_prob;
32 } object;
33
34
37 class CV_EXPORTS InferBbox
38 {
39 public:
45 InferBbox(Mat _delta_bbox, Mat _class_scores, Mat _conf_scores);
46
49 void filter(double thresh = 0.8);
50
53 std::vector<object> detections;
54
55 protected:
59 void transform_bboxes(std::vector<std::vector<double> > *bboxes);
60
64 void final_probability_dist(std::vector<std::vector<double> > *final_probs);
65
70 void transform_bboxes_inv(std::vector<std::vector<double> > *pre,
71 std::vector<std::vector<double> > *post);
72
76 void assert_predictions(std::vector<std::vector<double> > *min_max_boxes);
77
85 void filter_top_n(std::vector<std::vector<double> > *probs,
86 std::vector<std::vector<double> > *boxes,
87 std::vector<std::vector<double> > &top_n_boxes,
88 std::vector<size_t> &top_n_idxs,
89 std::vector<double> &top_n_probs);
90
96 void nms_wrapper(std::vector<std::vector<double> > &top_n_boxes,
97 std::vector<size_t> &top_n_idxs,
98 std::vector<double> &top_n_probs);
99
104 std::vector<bool> non_maximal_suppression(std::vector<std::vector<double> >
105 *boxes, std::vector<double> *probs);
106
112 void intersection_over_union(std::vector<std::vector<double> > *boxes,
113 std::vector<double> *base_box, std::vector<double> *iou);
114
115 static inline bool comparator (std::pair<double, size_t> l1,
116 std::pair<double, size_t> l2)
117 {
118 return l1.first > l2.first;
119 }
120
121 private:
122 Mat delta_bbox;
123 Mat class_scores;
124 Mat conf_scores;
125
126 unsigned int image_width;
127 unsigned int image_height;
128
129 unsigned int W, H;
130 std::vector<std::vector<double> > anchors_values;
131 std::vector<std::pair<double, double> > anchor_center;
132 std::vector<std::pair<double, double> > anchor_shapes;
133
134 std::vector<std::string> label_map;
135
136 unsigned int num_classes;
137 unsigned int anchors_per_grid;
138 size_t anchors;
139 double intersection_thresh;
140 double nms_intersection_thresh;
141 size_t n_top_detections;
142 double epsilon;
143 };
144
146} // namespace dnn_objdetect
147} // namespace cv
148 #endif
n-dimensional dense array class
Definition: mat.hpp:802
A class to post process model predictions
Definition: core_detect.hpp:38
void transform_bboxes(std::vector< std::vector< double > > *bboxes)
Transform relative coordinates from ConvDet to bounding box coordinates
void filter(double thresh=0.8)
Filters the bounding boxes.
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]
InferBbox(Mat _delta_bbox, Mat _class_scores, Mat _conf_scores)
Default constructer
std::vector< bool > non_maximal_suppression(std::vector< std::vector< double > > *boxes, std::vector< double > *probs)
Applies Non-Maximal Supression
std::vector< object > detections
Vector which holds the final detections of the model
Definition: core_detect.hpp:53
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
void final_probability_dist(std::vector< std::vector< double > > *final_probs)
Computes final probability values of each bounding box
void assert_predictions(std::vector< std::vector< double > > *min_max_boxes)
Ensures that the bounding box values are within image boundaries
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
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
cv
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Structure to hold the details pertaining to a single bounding box
Definition: core_detect.hpp:26