1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016, 2020 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Alex Vong <alexvong1995@gmail.com>
6 ;;; Copyright © 2021 Andy Tai <atai@atai.org>
7 ;;; Copyright © 2021 Nicolas Goaziou <mail@nicolasgoaziou.fr>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages ocr)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix build-system cmake)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system python)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages backup)
35 #:use-module (gnu packages check)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages curl)
38 #:use-module (gnu packages djvu)
39 #:use-module (gnu packages docbook)
40 #:use-module (gnu packages documentation)
41 #:use-module (gnu packages enchant)
42 #:use-module (gnu packages gettext)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages gtk)
45 #:use-module (gnu packages icu4c)
46 #:use-module (gnu packages pdf)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages python)
49 #:use-module (gnu packages qt)
50 #:use-module (gnu packages scanner)
51 #:use-module (gnu packages xml)
52 #:use-module (gnu packages image))
60 (uri (string-append "mirror://gnu/ocrad/ocrad-"
64 "0divffvcaim89g4pvqs8kslbcxi475bcl3b4ynphf284k9zfdgx9"))))
65 (build-system gnu-build-system)
66 (native-inputs `(("lzip" ,lzip)))
67 (home-page "https://www.gnu.org/software/ocrad/")
68 (synopsis "Optical character recognition based on feature extraction")
70 "GNU Ocrad is an optical character recognition program based on a
71 feature extraction method. It can read images in PBM, PGM or PPM formats and
72 it produces text in 8-bit or UTF-8 formats.")
73 (license license:gpl3+)))
75 (define-public tesseract-ocr
76 ;; There are useful commits beyond the last official stable release.
77 (let ((commit "97079fa353557af6df86fd20b5d2e0dff5d8d5df")
80 (name "tesseract-ocr")
81 (version (git-version "4.1.1" revision commit))
86 (url "https://github.com/tesseract-ocr/tesseract")
88 (file-name (git-file-name name version))
91 "11137a4aaay7qp64vdjd83hz1l089nzi5a0ql0qgk8gn79pyhi98"))))
92 (build-system gnu-build-system)
96 ("leptonica" ,leptonica)
98 ("python-wrapper" ,python-wrapper)))
100 `(("asciidoc" ,asciidoc)
101 ("autoconf" ,autoconf)
102 ("automake" ,automake)
103 ("docbook-xsl" ,docbook-xsl)
104 ("libarchive" ,libarchive)
108 ("pkg-config" ,pkg-config)
109 ("xsltproc" ,libxslt)))
112 (let ((leptonica (assoc-ref %build-inputs "leptonica")))
113 (list (string-append "LIBLEPT_HEADERSDIR=" leptonica "/include")))
114 #:tests? #f ; Tests currently result in a segfault
116 (modify-phases %standard-phases
117 (add-after 'unpack 'fix-docbook
118 (lambda* (#:key inputs #:allow-other-keys)
119 ;; Don't attempt to download XSL schema.
120 (substitute* "doc/Makefile.am"
121 (("http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl")
122 (string-append (assoc-ref inputs "docbook-xsl")
123 "/xml/xsl/docbook-xsl-"
124 ,(package-version docbook-xsl)
125 "/manpages/docbook.xsl")))))
126 (add-after 'install 'build-training
128 (invoke "make" "training")))
129 (add-after 'build-training 'install-training
131 (invoke "make" "training-install"))))))
132 (home-page "https://github.com/tesseract-ocr/tesseract")
133 (synopsis "Optical character recognition engine")
135 "Tesseract is an optical character recognition (OCR) engine with very
136 high accuracy. It supports many languages, output text formatting, hOCR
137 positional information and page layout analysis. Several image formats are
138 supported through the Leptonica library. It can also detect whether text is
139 monospaced or proportional.")
140 (license license:asl2.0))))
142 (define-public gimagereader
144 (name "gimagereader")
150 "https://github.com/manisandro/gImageReader/releases"
151 "/download/v" version "/"
152 "gimagereader-" version ".tar.xz"))
154 (base32 "1pghffb55k3wq33nbn9fi0lmjbldpmvqs2msnvss8bxz1k1ck23n"))))
155 (build-system cmake-build-system)
157 `(#:tests? #f ;no test
158 #:configure-flags (list "-DENABLE_VERSIONCHECK=0")
160 (modify-phases %standard-phases
161 (add-after 'unpack 'fix-build
162 ;; XXX: Prevent compilation error: "incomplete type ‘QUrl’ used in
163 ;; nested name specifier". Fixed upstream as
164 ;; 6209e25dab20b233e399ff36fabe4252db0f9e44. It can be removed in
167 (with-directory-excursion "qt/src/hocr"
168 (substitute* '("HOCROdtExporter.cc" "HOCRTextExporter.cc")
169 (("#include <QMessageBox>\n" all)
170 (string-append all "#include <QUrl>\n"))))
173 `(("gettext" ,gettext-minimal)
174 ("intltool" ,intltool)
175 ("pkg-config" ,pkg-config)))
177 `(("enchant" ,enchant)
178 ("djvulibre" ,djvulibre)
179 ("leptonica" ,leptonica)
181 ("poppler-qt5" ,poppler-qt5)
182 ("sane-backends" ,sane-backends)
186 ("tesseract" ,tesseract-ocr)))
187 (home-page "https://github.com/manisandro/gImageReader")
188 (synopsis "Qt front-end to tesseract-ocr")
190 "gImageReader is a Qt front-end to Tesseract optical character
191 recognition (OCR) software.
193 gImageReader supports automatic page layout detection but the user can
194 also manually define and adjust the recognition regions. It is
195 possible to import images from disk, scanning devices, clipboard and
196 screenshots. gImageReader also supports multipage PDF documents.
197 Recognized text is displayed directly next to the image and basic text
198 editing including search/replace and removing of line breaks is
199 possible. Spellchecking for the output text is also supported if the
200 corresponding dictionaries are installed.")
201 (license license:gpl3+)))
203 (define-public zinnia
204 (let* ((commit "581faa8f6f15e4a7b21964be3a5ec36265c80e5b")
206 ;; version copied from 'configure.in'
207 (version (git-version "0.07" revision commit)))
215 (url "https://github.com/taku910/zinnia")
219 "1izjy5qw6swg0rs2ym2i72zndb90mwrfbd1iv8xbpwckbm4899lg"))
220 (file-name (git-file-name name version))
221 (modules '((guix build utils)
224 (snippet ; remove unnecessary files with potentially different license
226 (for-each delete-file-recursively
228 (negate (cut member <> '("zinnia"
231 (build-system gnu-build-system)
234 (modify-phases %standard-phases
238 (for-each make-file-writable
239 '("config.log" "config.status"))
241 (home-page "https://taku910.github.io/zinnia/")
242 (synopsis "Online hand recognition system with machine learning")
244 "Zinnia is a simple, customizable and portable online hand recognition
245 system based on Support Vector Machines. Zinnia simply receives user pen
246 strokes as a sequence of coordinate data and outputs n-best characters sorted
247 by SVM confidence. To keep portability, Zinnia doesn't have any rendering
248 functionality. In addition to recognition, Zinnia provides training module
249 that allows us to create any hand-written recognition systems with low-cost.")
250 (license (list license:bsd-3 ; all files except...
251 (license:non-copyleft ; some autotools related files
252 "file://zinnia/aclocal.m4")
253 license:x11 ; 'install-sh'
254 license:public-domain))))) ; 'install-sh'
256 ;;; python 2 bindings, license under the same terms as zinnia
257 (define-public python2-zinnia
260 (name "python2-zinnia")
261 (build-system python-build-system)
263 `(#:python ,python-2 ; CObject API is used, it was removed in Python 3.2
264 #:tests? #f ; avoid circular dependency on tegaki-zinnia-japanese
266 (modify-phases %standard-phases
267 (add-after 'unpack 'chdir
269 (chdir "zinnia/python")
272 `(("zinnia" ,zinnia)))))