forked from GSam/Capture2Text
-
Notifications
You must be signed in to change notification settings - Fork 3
/
OcrEngine.h
86 lines (65 loc) · 2.65 KB
/
OcrEngine.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
/*
Copyright (C) 2010-2017 Christopher Brochtrup
This file is part of Capture2Text.
Capture2Text is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Capture2Text is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Capture2Text. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OCR_ENGINE_H
#define OCR_ENGINE_H
#include <QString>
#include <QStringList>
#include <QMap>
#include <QMutex>
#include <QRect>
#if defined( Q_OS_WIN32 ) || defined( Q_OS_MAC )
#include "tesseract/baseapi.h"
#else
#include "baseapi.h"
#endif
#include "allheaders.h"
class OcrEngine
{
public:
OcrEngine();
~OcrEngine();
static QString getTessdataPath();
static QStringList getInstalledLangs();
static bool isLangInstalled(QString lang);
static QString getFirstInstalledLang();
bool setLang(QString lang);
QString performOcr(PIX *pixs, bool singleLine);
QString getLang() { return lang; }
bool getVerticalOrientation() const { return verticalOrientation; }
void setVerticalOrientation(bool value) { verticalOrientation = value; }
static QString altLangToLang(QString ocrLang);
QString getWhitelist() const { return whitelist; }
void setWhitelist(const QString &value) { whitelist = value; }
QString getBlacklist() const { return blacklist; }
void setBlacklist(const QString &value) { blacklist = value; }
QString getConfigFile() const { return configFile; }
void setConfigFile(const QString &value) { configFile = value.trimmed(); }
private:
bool isLangCodeInstalled(QString langCode);
static QMap<QString, QString> populateLangMap();
static QMap<QString, QString> populateCodeMap();
static QMap<QString, QString> populateAltLangMap();
QMutex mutex;
QString lang;
bool verticalOrientation = false;
QString whitelist;
QString blacklist;
QString configFile;
tesseract::TessBaseAPI *tessApi;
static const QMap<QString, QString> mapLang; // Key = Lang name, Value = Tesseract Code
static const QMap<QString, QString> mapCode; // Key = Tesseract Code, Value = Lang name
static const QMap<QString, QString> mapLangAlt; // Key = Alt Lang name, Value = Lang name
};
#endif // OCR_ENGINE_H