@@ -24,49 +24,51 @@ class DBPostProcessor {
2424 void GetContourArea (const std::vector<std::vector<float >> &box,
2525 float unclip_ratio, float &distance);
2626
27- cv::RotatedRect UnClip (std::vector<std::vector<float >> box,
27+ cv::RotatedRect UnClip (const std::vector<std::vector<float >> & box,
2828 const float &unclip_ratio);
2929
30- float **Mat2Vec (cv::Mat mat);
30+ float **Mat2Vec (const cv::Mat & mat);
3131
3232 std::vector<std::vector<int >>
33- OrderPointsClockwise (std::vector<std::vector<int >> pts);
33+ OrderPointsClockwise (const std::vector<std::vector<int >> & pts);
3434
35- std::vector<std::vector<float >> GetMiniBoxes (cv::RotatedRect box,
35+ std::vector<std::vector<float >> GetMiniBoxes (const cv::RotatedRect & box,
3636 float &ssid);
3737
38- float BoxScoreFast (std::vector<std::vector<float >> box_array, cv::Mat pred);
39- float PolygonScoreAcc (std::vector<cv::Point> contour, cv::Mat pred);
38+ float BoxScoreFast (const std::vector<std::vector<float >> &box_array,
39+ const cv::Mat &pred);
40+ float PolygonScoreAcc (const std::vector<cv::Point> &contour,
41+ const cv::Mat &pred);
4042
4143 std::vector<std::vector<std::vector<int >>>
42- BoxesFromBitmap (const cv::Mat pred, const cv::Mat bitmap,
44+ BoxesFromBitmap (const cv::Mat & pred, const cv::Mat & bitmap,
4345 const float &box_thresh, const float &det_db_unclip_ratio,
4446 const std::string &det_db_score_mode);
4547
46- std::vector<std::vector<std::vector<int >>>
47- FilterTagDetRes (std::vector<std::vector<std::vector<int >>> boxes,
48- float ratio_h, float ratio_w, cv::Mat srcimg);
48+ void FilterTagDetRes (std::vector<std::vector<std::vector<int >>> &boxes,
49+ float ratio_h, float ratio_w, const cv::Mat &srcimg);
4950
5051private:
51- static bool XsortInt (std::vector<int > a, std::vector<int > b);
52+ static bool XsortInt (const std::vector<int > & a, const std::vector<int > & b);
5253
53- static bool XsortFp32 (std::vector<float > a, std::vector<float > b);
54+ static bool XsortFp32 (const std::vector<float > &a,
55+ const std::vector<float > &b);
5456
55- std::vector<std::vector<float >> Mat2Vector (cv::Mat mat);
57+ std::vector<std::vector<float >> Mat2Vector (const cv::Mat & mat);
5658
57- inline int _max (int a, int b) { return a >= b ? a : b; }
59+ inline int _max (int a, int b) const noexcept { return a >= b ? a : b; }
5860
59- inline int _min (int a, int b) { return a >= b ? b : a; }
61+ inline int _min (int a, int b) const noexcept { return a >= b ? b : a; }
6062
61- template <class T > inline T clamp (T x, T min, T max) {
63+ template <class T > inline T clamp (T x, T min, T max) const noexcept {
6264 if (x > max)
6365 return max;
6466 if (x < min)
6567 return min;
6668 return x;
6769 }
6870
69- inline float clampf (float x, float min, float max) {
71+ inline float clampf (float x, float min, float max) const noexcept {
7072 if (x > max)
7173 return max;
7274 if (x < min)
@@ -77,37 +79,45 @@ class DBPostProcessor {
7779
7880class TablePostProcessor {
7981public:
80- void init (std::string label_path, bool merge_no_span_structure = true );
81- void Run (std::vector<float > &loc_preds, std::vector<float > &structure_probs,
82- std::vector<float > &rec_scores, std::vector<int > &loc_preds_shape,
83- std::vector<int > &structure_probs_shape,
82+ void init (const std::string &label_path, bool merge_no_span_structure = true );
83+ void Run (const std::vector<float > &loc_preds,
84+ const std::vector<float > &structure_probs,
85+ std::vector<float > &rec_scores,
86+ const std::vector<int > &loc_preds_shape,
87+ const std::vector<int > &structure_probs_shape,
8488 std::vector<std::vector<std::string>> &rec_html_tag_batch,
8589 std::vector<std::vector<std::vector<int >>> &rec_boxes_batch,
86- std::vector<int > &width_list, std::vector<int > &height_list);
90+ const std::vector<int > &width_list,
91+ const std::vector<int > &height_list);
8792
8893private:
8994 std::vector<std::string> label_list_;
90- std::string end = " eos" ;
91- std::string beg = " sos" ;
95+ const std::string end = " eos" ;
96+ const std::string beg = " sos" ;
9297};
9398
9499class PicodetPostProcessor {
95100public:
96- void init (std::string label_path, const double score_threshold = 0.4 ,
101+ void init (const std::string & label_path, const double score_threshold = 0.4 ,
97102 const double nms_threshold = 0.5 ,
98103 const std::vector<int > &fpn_stride = {8 , 16 , 32 , 64 });
99104 void Run (std::vector<StructurePredictResult> &results,
100- std::vector<std::vector<float >> outs, std::vector<int > ori_shape,
101- std::vector<int > resize_shape, int eg_max);
102- std::vector<int > fpn_stride_ = {8 , 16 , 32 , 64 };
105+ const std::vector<std::vector<float >> &outs,
106+ const std::vector<int > &ori_shape,
107+ const std::vector<int > &resize_shape, int eg_max);
108+ inline size_t fpn_stride_size () const { return fpn_stride_.size (); }
103109
104110private:
105- StructurePredictResult disPred2Bbox (std::vector<float > bbox_pred, int label,
106- float score, int x, int y, int stride,
107- std::vector<int > im_shape, int reg_max);
111+ StructurePredictResult disPred2Bbox (const std::vector<float > &bbox_pred,
112+ int label, float score, int x, int y,
113+ int stride,
114+ const std::vector<int > &im_shape,
115+ int reg_max);
108116 void nms (std::vector<StructurePredictResult> &input_boxes,
109117 float nms_threshold);
110118
119+ std::vector<int > fpn_stride_ = {8 , 16 , 32 , 64 };
120+
111121 std::vector<std::string> label_list_;
112122 double score_threshold_ = 0.4 ;
113123 double nms_threshold_ = 0.5 ;
0 commit comments