Adjust to rescent tesseract version
This commit is contained in:
parent
f15fb29ac1
commit
12cb3bf4ab
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include <leptonica/allheaders.h>
|
#include <leptonica/allheaders.h>
|
||||||
|
|
||||||
#include <tesseract/host.h>
|
|
||||||
|
|
||||||
#include "ImageProcessing.h"
|
#include "ImageProcessing.h"
|
||||||
#include "StAssert.h"
|
#include "StAssert.h"
|
||||||
|
|
||||||
@ -128,6 +126,7 @@ Pix * prepareImage (const QImage &image, int preferredScale) {
|
|||||||
|
|
||||||
Pix *scaled = gray;
|
Pix *scaled = gray;
|
||||||
if (preferredScale > 0) {
|
if (preferredScale > 0) {
|
||||||
|
const auto MAX_INT16 = 0x7fff;
|
||||||
float maxScaleX = MAX_INT16 / double (gray->w);
|
float maxScaleX = MAX_INT16 / double (gray->w);
|
||||||
float scaleX = std::min (float (preferredScale), maxScaleX);
|
float scaleX = std::min (float (preferredScale), maxScaleX);
|
||||||
float maxScaleY = MAX_INT16 / double (gray->h);
|
float maxScaleY = MAX_INT16 / double (gray->h);
|
||||||
|
@ -23,12 +23,12 @@ const QStringList &LanguageHelper::availableOcrLanguages () const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList LanguageHelper::availableOcrLanguages (const QString &path) const {
|
QStringList LanguageHelper::availableOcrLanguages (const QString &path) const {
|
||||||
QDir dir (path + "/tessdata/");
|
QDir dir (path);
|
||||||
if (!dir.exists ()) {
|
if (!dir.exists ()) {
|
||||||
return QStringList ();
|
return QStringList ();
|
||||||
}
|
}
|
||||||
QStringList items;
|
QStringList items;
|
||||||
QStringList files = dir.entryList (QStringList () << "*.traineddata", QDir::Files);
|
QStringList files = dir.entryList ({"*.traineddata"}, QDir::Files);
|
||||||
foreach (const QString &file, files) {
|
foreach (const QString &file, files) {
|
||||||
QString lang = file.left (file.indexOf ("."));
|
QString lang = file.left (file.indexOf ("."));
|
||||||
items << lang;
|
items << lang;
|
||||||
|
@ -24,9 +24,6 @@ void Recognizer::applySettings () {
|
|||||||
|
|
||||||
tessDataDir_ = settings.value (settings_names::tessDataPlace,
|
tessDataDir_ = settings.value (settings_names::tessDataPlace,
|
||||||
settings_values::tessDataPlace).toString ();
|
settings_values::tessDataPlace).toString ();
|
||||||
if (tessDataDir_.right (1) != "/") {
|
|
||||||
tessDataDir_ += "/";
|
|
||||||
}
|
|
||||||
ocrLanguage_ = settings.value (settings_names::ocrLanguage,
|
ocrLanguage_ = settings.value (settings_names::ocrLanguage,
|
||||||
settings_values::ocrLanguage).toString ();
|
settings_values::ocrLanguage).toString ();
|
||||||
imageScale_ = settings.value (settings_names::imageScale,
|
imageScale_ = settings.value (settings_names::imageScale,
|
||||||
|
@ -152,15 +152,11 @@ void SettingsEditor::saveSettings () const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SettingsEditor::openTessdataDialog () {
|
void SettingsEditor::openTessdataDialog () {
|
||||||
QString path = QFileDialog::getExistingDirectory (this, tr ("Путь к tessdata"));
|
QString path = QFileDialog::getExistingDirectory (this, tr ("Path to tessdata"));
|
||||||
if (path.isEmpty ()) {
|
if (path.isEmpty ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QDir dir (path);
|
ui->tessdataEdit->setText (path);
|
||||||
if (dir.dirName () == QString ("tessdata")) {
|
|
||||||
dir.cdUp ();
|
|
||||||
}
|
|
||||||
ui->tessdataEdit->setText (dir.path ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsEditor::loadSettings () {
|
void SettingsEditor::loadSettings () {
|
||||||
|
@ -270,11 +270,8 @@
|
|||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="toolTip">
|
|
||||||
<string><html><head/><body><p>Необходимо для распознавания.</p><p>Скачивается отсюда: <a href="https://github.com/tesseract-ocr/tessdata"><span style=" text-decoration: underline; color:#7593bc;">https://github.com/tesseract-ocr/tessdata</span></a></p><p>&quot;./&quot; означает, что папка &quot;tessdata&quot; находится в одной директории с исполняемым файлом программы.</p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Путь к tessdata</string>
|
<string>Path to tessdata</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>tessdataEdit</cstring>
|
<cstring>tessdataEdit</cstring>
|
||||||
@ -282,7 +279,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="tessdataEdit"/>
|
<widget class="QLineEdit" name="tessdataEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Enter path</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QToolButton" name="tessdataButton">
|
<widget class="QToolButton" name="tessdataButton">
|
||||||
|
Loading…
Reference in New Issue
Block a user