nndeploy C++ API  0.2.0
nndeploy C++ API
ocr_postprocess_op.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstring>
4 #include <fstream>
5 #include <iomanip>
6 #include <iostream>
7 #include <map>
8 #include <numeric>
9 #include <ostream>
10 #include <vector>
11 
12 #include "nndeploy/base/macro.h"
13 
14 #include "nndeploy/ocr/clipper.h"
15 #include "opencv2/core.hpp"
16 #include "opencv2/imgproc.hpp"
17 
18 namespace nndeploy {
19 namespace ocr {
20 
22  public:
23  void GetContourArea(const std::vector<std::vector<float>> &box,
24  float unclip_ratio, float &distance);
25 
26  cv::RotatedRect UnClip(std::vector<std::vector<float>> box,
27  const float &unclip_ratio);
28 
29  float **Mat2Vec(cv::Mat mat);
30 
31  std::vector<std::vector<int>> OrderPointsClockwise(
32  std::vector<std::vector<int>> pts);
33 
34  std::vector<std::vector<float>> GetMiniBoxes(cv::RotatedRect box,
35  float &ssid);
36 
37  float BoxScoreFast(std::vector<std::vector<float>> box_array, cv::Mat pred);
38  float PolygonScoreAcc(std::vector<cv::Point> contour, cv::Mat pred);
39 
40  std::vector<std::vector<std::vector<int>>> BoxesFromBitmap(
41  const cv::Mat pred, const cv::Mat bitmap, const float &box_thresh,
42  const float &det_db_unclip_ratio, const std::string &det_db_score_mode);
43 
44  std::vector<std::vector<std::vector<int>>> FilterTagDetRes(
45  std::vector<std::vector<std::vector<int>>> boxes,
46  const std::array<int, 4> &det_img_info);
47 
48  private:
49  static bool XsortInt(std::vector<int> a, std::vector<int> b);
50 
51  static bool XsortFp32(std::vector<float> a, std::vector<float> b);
52 
53  std::vector<std::vector<float>> Mat2Vector(cv::Mat mat);
54 
55  inline int _max(int a, int b) { return a >= b ? a : b; }
56 
57  inline int _min(int a, int b) { return a >= b ? b : a; }
58 
59  template <class T>
60  inline T clamp(T x, T min, T max) {
61  if (x > max) return max;
62  if (x < min) return min;
63  return x;
64  }
65 
66  inline float clampf(float x, float min, float max) {
67  if (x > max) return max;
68  if (x < min) return min;
69  return x;
70  }
71 };
72 
73 } // namespace ocr
74 } // namespace nndeploy
cv::RotatedRect UnClip(std::vector< std::vector< float >> box, const float &unclip_ratio)
std::vector< std::vector< std::vector< int > > > FilterTagDetRes(std::vector< std::vector< std::vector< int >>> boxes, const std::array< int, 4 > &det_img_info)
std::vector< std::vector< std::vector< int > > > BoxesFromBitmap(const cv::Mat pred, const cv::Mat bitmap, const float &box_thresh, const float &det_db_unclip_ratio, const std::string &det_db_score_mode)
float BoxScoreFast(std::vector< std::vector< float >> box_array, cv::Mat pred)
std::vector< std::vector< int > > OrderPointsClockwise(std::vector< std::vector< int >> pts)
float PolygonScoreAcc(std::vector< cv::Point > contour, cv::Mat pred)
float ** Mat2Vec(cv::Mat mat)
void GetContourArea(const std::vector< std::vector< float >> &box, float unclip_ratio, float &distance)
std::vector< std::vector< float > > GetMiniBoxes(cv::RotatedRect box, float &ssid)
#define NNDEPLOY_CC_API
api
Definition: macro.h:29