Skip to content
Snippets Groups Projects
Commit 1c7d55a3 authored by Balló György's avatar Balló György :flag_hu:
Browse files

Move gimagereader from AUR with 102 votes

And its dependencies: gtkspellmm, qtspell.
parents
No related branches found
Tags 3.3.0-1
No related merge requests found
PKGBUILD 0 → 100644
# Maintainer: Balló György <ballogyor+arch at gmail dot com>
pkgbase=gimagereader
pkgname=(gimagereader-gtk gimagereader-qt gimagereader-common)
pkgver=3.3.0
pkgrel=1
url="https://github.com/manisandro/gImageReader"
pkgdesc="Gtk/Qt front-end to tesseract-ocr"
arch=(x86_64)
license=(GPL3)
depends=(desktop-file-utils djvulibre gtksourceviewmm gtkspellmm libxml++ libzip podofo
poppler-glib poppler-qt5 qt5-imageformats qtspell quazip sane tesseract)
makedepends=(cmake intltool python-gobject)
source=(https://github.com/manisandro/gImageReader/releases/download/v$pkgver/$pkgbase-$pkgver.tar.xz
setlocale.patch
openmp.patch)
sha256sums=('91615af41e89170aadaae68cb0db94eb62abdd5b308e8a5162477ba9baf6efe9'
'd007abed0fd16e3db340b3d5114a7de7b7b1cdb858f9fce51655df98a02c1baa'
'ee84de7fee390ee54152b4e332e50d8f585b0c9a3aa8b40a04f865b5250607c2')
prepare() {
[[ -d build-gtk ]] || mkdir build-gtk
[[ -d build-qt ]] || mkdir build-qt
[[ -d gimagereader-common ]] || mkdir gimagereader-common
cd $pkgbase-$pkgver
# Set locale to C before constructing TessBaseAPI
# https://github.com/manisandro/gImageReader/issues/375
patch -Np1 -i ../setlocale.patch
# Run OpenMP once before calling tesseract
# https://github.com/manisandro/gImageReader/issues/285
patch -Np1 -i ../openmp.patch
}
build() {
cd build-gtk
cmake -G "Unix Makefiles" ../$pkgbase-$pkgver/ \
-DCMAKE_INSTALL_PREFIX=/usr \
-DINTERFACE_TYPE=gtk
make
cd ../build-qt
cmake -G "Unix Makefiles" ../$pkgbase-$pkgver/ \
-DCMAKE_INSTALL_PREFIX=/usr \
-DINTERFACE_TYPE=qt5
make
}
package_gimagereader-gtk() {
pkgdesc="Gtk front-end to tesseract-ocr"
depends=(gimagereader-common djvulibre gtksourceviewmm gtkspellmm libxml++ libzip podofo poppler-glib sane tesseract)
cd build-gtk
make DESTDIR="$pkgdir" install
# Split gimagereader-common
mv "$pkgdir"/usr/share/{doc,icons,locale} \
"$srcdir/gimagereader-common/"
}
package_gimagereader-qt() {
pkgdesc="Qt front-end to tesseract-ocr"
depends=(gimagereader-common desktop-file-utils djvulibre podofo poppler-qt5 qt5-imageformats qtspell quazip sane tesseract)
cd build-qt
make DESTDIR="$pkgdir" install
# Split gimagereader-common
rm -r "$pkgdir"/usr/share/{doc,icons,locale}
}
package_gimagereader-common() {
pkgdesc="Common files for gImageReader"
depends=(hicolor-icon-theme)
mkdir -p "$pkgdir"/usr/share
mv gimagereader-common/* "$pkgdir/usr/share"
}
From 122ed08d72265e3abb02c48c4be804d793058fc9 Mon Sep 17 00:00:00 2001
From: Philip Rinn <rinni@inventati.org>
Date: Fri, 5 Jan 2018 15:22:47 +0100
Subject: [PATCH] Run OpenMP once before calling tesseract (fixes: #285)
---
gtk/src/main.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gtk/src/main.cc b/gtk/src/main.cc
index a2668e4..9fec77a 100644
--- a/gtk/src/main.cc
+++ b/gtk/src/main.cc
@@ -94,6 +94,12 @@ int main (int argc, char *argv[]) {
}
#endif
+ // Run OpenMP once before tesseract is called, otherwise it might be
+ // _very_ slow, see https://github.com/manisandro/gImageReader/issues/285
+ // Sleep 1 millisecond to prevent being optimized out.
+ #pragma omp parallel for schedule(static)
+ for(int i = 0; i < 1; i++) { sleep(1); }
+
std::string localeDir = Glib::build_filename(pkgDir, "share", "locale");
bindtextdomain(GETTEXT_PACKAGE, localeDir.c_str());
From 46390fee9a01ea7c4d85cd0757a6a258c8ebe600 Mon Sep 17 00:00:00 2001
From: Sandro Mani <manisandro@gmail.com>
Date: Sun, 30 Sep 2018 23:35:26 +0200
Subject: [PATCH] Set locale to C before constructing TessBaseAPI
---
gtk/src/Recognizer.cc | 3 +++
gtk/src/hocr/OutputEditorHOCR.cc | 3 +++
qt/src/Recognizer.cc | 3 +++
qt/src/hocr/OutputEditorHOCR.cc | 3 +++
4 files changed, 12 insertions(+)
diff --git a/gtk/src/Recognizer.cc b/gtk/src/Recognizer.cc
index 564a3f2..2cbeb93 100644
--- a/gtk/src/Recognizer.cc
+++ b/gtk/src/Recognizer.cc
@@ -148,7 +148,10 @@ static void tessCrashHandler(int /*signal*/) {
captured += buf;
}
} while(bytesRead == sizeof(buf) - 1);
+ std::string current = setlocale(LC_ALL, NULL);
+ setlocale(LC_ALL, "C");
tesseract::TessBaseAPI tess;
+ setlocale(LC_ALL, current.c_str());
Glib::ustring errMsg = Glib::ustring::compose(_("Tesseract crashed with the following message:\n\n"
"%1\n\n"
"This typically happens for one of the following reasons:\n"
diff --git a/gtk/src/hocr/OutputEditorHOCR.cc b/gtk/src/hocr/OutputEditorHOCR.cc
index ffd7250..45679df 100644
--- a/gtk/src/hocr/OutputEditorHOCR.cc
+++ b/gtk/src/hocr/OutputEditorHOCR.cc
@@ -972,7 +972,10 @@ bool OutputEditorHOCR::save(const std::string& filename) {
Utils::message_dialog(Gtk::MESSAGE_ERROR, _("Failed to save output"), _("Check that you have writing permissions in the selected folder."));
return false;
}
+ std::string current = setlocale(LC_ALL, NULL);
+ setlocale(LC_ALL, "C");
tesseract::TessBaseAPI tess;
+ setlocale(LC_ALL, current.c_str());
Glib::ustring header = Glib::ustring::compose(
"<!DOCTYPE html>\n"
"<html>\n"
diff --git a/qt/src/Recognizer.cc b/qt/src/Recognizer.cc
index 0c4b0dd..7ff38cb 100644
--- a/qt/src/Recognizer.cc
+++ b/qt/src/Recognizer.cc
@@ -135,7 +135,10 @@ static void tessCrashHandler(int /*signal*/) {
captured += buf;
}
} while(bytesRead == sizeof(buf) - 1);
+ QByteArray current = setlocale(LC_ALL, NULL);
+ setlocale(LC_ALL, "C");
tesseract::TessBaseAPI tess;
+ setlocale(LC_ALL, current.constData());
QString errMsg = QString(_("Tesseract crashed with the following message:\n\n"
"%1\n\n"
"This typically happens for one of the following reasons:\n"
diff --git a/qt/src/hocr/OutputEditorHOCR.cc b/qt/src/hocr/OutputEditorHOCR.cc
index bb3759a..c59e3ee 100644
--- a/qt/src/hocr/OutputEditorHOCR.cc
+++ b/qt/src/hocr/OutputEditorHOCR.cc
@@ -842,7 +842,10 @@ bool OutputEditorHOCR::save(const QString& filename) {
QMessageBox::critical(MAIN, _("Failed to save output"), _("Check that you have writing permissions in the selected folder."));
return false;
}
+ QByteArray current = setlocale(LC_ALL, NULL);
+ setlocale(LC_ALL, "C");
tesseract::TessBaseAPI tess;
+ setlocale(LC_ALL, current.constData());
QString header = QString(
"<!DOCTYPE html>\n"
"<html>\n"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment