| 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 | ;;; |
| 7 | ;;; This file is part of GNU Guix. |
| 8 | ;;; |
| 9 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
| 10 | ;;; under the terms of the GNU General Public License as published by |
| 11 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
| 12 | ;;; your option) any later version. |
| 13 | ;;; |
| 14 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
| 15 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | ;;; GNU General Public License for more details. |
| 18 | ;;; |
| 19 | ;;; You should have received a copy of the GNU General Public License |
| 20 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | (define-module (gnu packages ocr) |
| 23 | #:use-module ((guix licenses) #:prefix license:) |
| 24 | #:use-module (guix packages) |
| 25 | #:use-module (guix download) |
| 26 | #:use-module (guix git-download) |
| 27 | #:use-module (guix build-system gnu) |
| 28 | #:use-module (guix build-system python) |
| 29 | #:use-module (gnu packages compression) |
| 30 | #:use-module (gnu packages python) |
| 31 | #:use-module (gnu packages image)) |
| 32 | |
| 33 | (define-public ocrad |
| 34 | (package |
| 35 | (name "ocrad") |
| 36 | (version "0.27") |
| 37 | (source (origin |
| 38 | (method url-fetch) |
| 39 | (uri (string-append "mirror://gnu/ocrad/ocrad-" |
| 40 | version ".tar.lz")) |
| 41 | (sha256 |
| 42 | (base32 |
| 43 | "0divffvcaim89g4pvqs8kslbcxi475bcl3b4ynphf284k9zfdgx9")))) |
| 44 | (build-system gnu-build-system) |
| 45 | (native-inputs `(("lzip" ,lzip))) |
| 46 | (home-page "https://www.gnu.org/software/ocrad/") |
| 47 | (synopsis "Optical character recognition based on feature extraction") |
| 48 | (description |
| 49 | "GNU Ocrad is an optical character recognition program based on a |
| 50 | feature extraction method. It can read images in PBM, PGM or PPM formats and |
| 51 | it produces text in 8-bit or UTF-8 formats.") |
| 52 | (license license:gpl3+))) |
| 53 | |
| 54 | (define-public tesseract-ocr |
| 55 | (package |
| 56 | (name "tesseract-ocr") |
| 57 | (version "3.04.01") |
| 58 | (source |
| 59 | (origin |
| 60 | (method git-fetch) |
| 61 | (uri (git-reference |
| 62 | (url "https://github.com/tesseract-ocr/tesseract") |
| 63 | (commit version))) |
| 64 | (file-name (git-file-name name version)) |
| 65 | (sha256 |
| 66 | (base32 "0h1x4z1h86n2gwknd0wck6gykkp99bmm02lg4a47a698g4az6ybv")))) |
| 67 | (build-system gnu-build-system) |
| 68 | (inputs |
| 69 | `(("leptonica" ,leptonica))) |
| 70 | (arguments |
| 71 | '(#:configure-flags |
| 72 | (let ((leptonica (assoc-ref %build-inputs "leptonica"))) |
| 73 | (list (string-append "LIBLEPT_HEADERSDIR=" leptonica "/include"))))) |
| 74 | (home-page "https://github.com/tesseract-ocr/tesseract") |
| 75 | (synopsis "Optical character recognition engine") |
| 76 | (description |
| 77 | "Tesseract is an optical character recognition (OCR) engine with very |
| 78 | high accuracy. It supports many languages, output text formatting, hOCR |
| 79 | positional information and page layout analysis. Several image formats are |
| 80 | supported through the Leptonica library. It can also detect whether text is |
| 81 | monospaced or proportional.") |
| 82 | (license license:asl2.0))) |
| 83 | |
| 84 | (define-public zinnia |
| 85 | (let* ((commit "581faa8f6f15e4a7b21964be3a5ec36265c80e5b") |
| 86 | (revision "1") |
| 87 | ;; version copied from 'configure.in' |
| 88 | (version (git-version "0.07" revision commit))) |
| 89 | (package |
| 90 | (name "zinnia") |
| 91 | (version version) |
| 92 | (source |
| 93 | (origin |
| 94 | (method git-fetch) |
| 95 | (uri (git-reference |
| 96 | (url "https://github.com/taku910/zinnia") |
| 97 | (commit commit))) |
| 98 | (sha256 |
| 99 | (base32 |
| 100 | "1izjy5qw6swg0rs2ym2i72zndb90mwrfbd1iv8xbpwckbm4899lg")) |
| 101 | (file-name (git-file-name name version)) |
| 102 | (modules '((guix build utils) |
| 103 | (ice-9 ftw) |
| 104 | (srfi srfi-26))) |
| 105 | (snippet ; remove unnecessary files with potentially different license |
| 106 | '(begin |
| 107 | (for-each delete-file-recursively |
| 108 | (scandir "." |
| 109 | (negate (cut member <> '("zinnia" |
| 110 | "." ".."))))) |
| 111 | #t)))) |
| 112 | (build-system gnu-build-system) |
| 113 | (arguments |
| 114 | `(#:phases |
| 115 | (modify-phases %standard-phases |
| 116 | (replace 'bootstrap |
| 117 | (lambda _ |
| 118 | (chdir "zinnia") |
| 119 | (for-each make-file-writable |
| 120 | '("config.log" "config.status")) |
| 121 | #t))))) |
| 122 | (home-page "https://taku910.github.io/zinnia/") |
| 123 | (synopsis "Online hand recognition system with machine learning") |
| 124 | (description |
| 125 | "Zinnia is a simple, customizable and portable online hand recognition |
| 126 | system based on Support Vector Machines. Zinnia simply receives user pen |
| 127 | strokes as a sequence of coordinate data and outputs n-best characters sorted |
| 128 | by SVM confidence. To keep portability, Zinnia doesn't have any rendering |
| 129 | functionality. In addition to recognition, Zinnia provides training module |
| 130 | that allows us to create any hand-written recognition systems with low-cost.") |
| 131 | (license (list license:bsd-3 ; all files except... |
| 132 | (license:non-copyleft ; some autotools related files |
| 133 | "file://zinnia/aclocal.m4") |
| 134 | license:x11 ; 'install-sh' |
| 135 | license:public-domain))))) ; 'install-sh' |
| 136 | |
| 137 | ;;; python 2 bindings, license under the same terms as zinnia |
| 138 | (define-public python2-zinnia |
| 139 | (package |
| 140 | (inherit zinnia) |
| 141 | (name "python2-zinnia") |
| 142 | (build-system python-build-system) |
| 143 | (arguments |
| 144 | `(#:python ,python-2 ; CObject API is used, it was removed in Python 3.2 |
| 145 | #:tests? #f ; avoid circular dependency on tegaki-zinnia-japanese |
| 146 | #:phases |
| 147 | (modify-phases %standard-phases |
| 148 | (add-after 'unpack 'chdir |
| 149 | (lambda _ |
| 150 | (chdir "zinnia/python") |
| 151 | #t))))) |
| 152 | (inputs |
| 153 | `(("zinnia" ,zinnia))))) |