-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsegmentation.h
executable file
·92 lines (77 loc) · 1.93 KB
/
segmentation.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef SEGMENTATION_H
#define SEGMENTATION_H
#include "preprocess.h"
#include <QObject>
#include <QFileDialog>
#include <QGraphicsItem>
#include <QImage>
#include <QDateTime>
#include <QtCore5Compat/QTextCodec>
#include <QDebug>
#include <QDateTime>
#include <QMessageBox>
#include <iostream>
#include <poppler/qt6/poppler-qt6.h>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
class Segmentation : public QObject
{
Q_OBJECT
private:
Mat binarizedMat;
Mat Visualization_V;
Mat Visualization_H;
QImage imageUnderProcess;
enum HistogramType
{
VERTICAL,
HORIZONTAL
};
int w; // just for the test.
struct Line
{
int start;
int end;
};
struct Word
{
int x_start;
int x_end;
int y_start;
int y_end;
};
struct pos
{
int x;
int y;
};
struct Candidate
{
int timeRepeated;
int value;
};
Candidate C;
Line line;
Word word;
QList<Line> geoLines;
QList<Word> geoWords;
public:
explicit Segmentation(QObject *parent = 0);
QList<Mat> tryCutWord(Mat imageIn);
QList<int> cutWhereWhite(QList<int> list);
QList<Mat> getCharactersInWord(Mat image, QList<int> posCuts);
void getPositionCutWord(Mat imageLine, int lineIndex);
int mostRedundantValue(QList<int> list);
QList<int> calculateBackProjection(Mat imageIn, HistogramType type);
Mat smoothingHistogram(Mat image);
static Mat copyRect(Mat image, int x1, int y1, int x2, int y2);
static Mat characterNormalization(Mat image);
QList<Mat> cutLine2Characters(QList<Mat> listImagesLines, int i);
QList<Mat> getCollectionOfLinesDetected(Mat image);
QList<Mat> segmentEntireDocument(Mat image);
void lineDetection(QList<int> histogramData);
void wordsDetection();
int averageLineHeight(QList<int> histogramData);
};
#endif // SEGMENTATION_H