-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstripes_solver.h
76 lines (52 loc) · 1.63 KB
/
stripes_solver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef STRIPES_SOLVER_H
#define STRIPES_SOLVER_H
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <numeric>
#include <vector>
#include <deque>
#include <string>
#include <tesseract/baseapi.h>
#include <opencv2/opencv.hpp>
#include <stripe_pair.h>
#include <fragment.h>
#include <utils.h>
using namespace std;
class StripesSolver {
public:
enum Metric {
PIXEL,
WORD
};
enum Composition {
GREEDY,
};
const tesseract::PageIteratorLevel tesseract_level {tesseract::RIL_WORD};
const double conf_thres {80};
string model_path;
int stripes_n {0};
vector<cv::Mat> stripes;
vector<int> comp_idx;
cv::Mat comp_img;
StripesSolver(const string & _model_path);
~StripesSolver();
void push(const cv::Mat & stripe_img);
bool reassemble(Metric _metric_mode, Composition comp_mode);
double m_metric_pixel(const Fragment & frag0, const Fragment & frag1);
double m_metric_word(const Fragment & frag0, const Fragment & frag1);
void save_result(const string & case_name);
private:
tesseract::TessBaseAPI * ocr;
cv::Mat merge_frags(const cv::Mat & in_frag0, const cv::Mat & in_frag1);
Metric metric_mode;
bool reassemble_greedy();
bool cross_seam(const cv::Rect & bbox, int seam_x);
bool detect_new_word( const string & word,
const cv::Rect & bbox,
const Fragment & frag,
const int offset_x=0);
const double overlap_thres {0.3};
double overlap(const cv::Rect & rect0, const cv::Rect & rect1, const int offset_x=0);
};
#endif