| 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 | (define-module (gnu packages ocr)
|
| 26 | #:use-module ((guix licenses) #:prefix license:)
|
| 27 | #:use-module (guix packages)
|
| 28 | #:use-module (guix download)
|
| 29 | #:use-module (guix gexp)
|
| 30 | #:use-module (guix git-download)
|
| 31 | #:use-module (guix build-system cmake)
|
| 32 | #:use-module (guix build-system copy)
|
| 33 | #:use-module (guix build-system gnu)
|
| 34 | #:use-module (guix build-system pyproject)
|
| 35 | #:use-module (guix build-system qt)
|
| 36 | #:use-module (gnu packages)
|
| 37 | #:use-module (gnu packages autotools)
|
| 38 | #:use-module (gnu packages backup)
|
| 39 | #:use-module (gnu packages check)
|
| 40 | #:use-module (gnu packages compression)
|
| 41 | #:use-module (gnu packages curl)
|
| 42 | #:use-module (gnu packages djvu)
|
| 43 | #:use-module (gnu packages docbook)
|
| 44 | #:use-module (gnu packages documentation)
|
| 45 | #:use-module (gnu packages enchant)
|
| 46 | #:use-module (gnu packages gettext)
|
| 47 | #:use-module (gnu packages glib)
|
| 48 | #:use-module (gnu packages gtk)
|
| 49 | #:use-module (gnu packages icu4c)
|
| 50 | #:use-module (gnu packages image)
|
| 51 | #:use-module (gnu packages pdf)
|
| 52 | #:use-module (gnu packages pkg-config)
|
| 53 | #:use-module (gnu packages python)
|
| 54 | #:use-module (gnu packages python-build)
|
| 55 | #:use-module (gnu packages python-science)
|
| 56 | #:use-module (gnu packages python-xyz)
|
| 57 | #:use-module (gnu packages qt)
|
| 58 | #:use-module (gnu packages scanner)
|
| 59 | #:use-module (gnu packages xml))
|
| 60 |
|
| 61 | (define-public ocrad
|
| 62 | (package
|
| 63 | (name "ocrad")
|
| 64 | (version "0.29")
|
| 65 | (source (origin
|
| 66 | (method url-fetch)
|
| 67 | (uri (string-append "mirror://gnu/ocrad/ocrad-"
|
| 68 | version ".tar.lz"))
|
| 69 | (sha256
|
| 70 | (base32
|
| 71 | "1sfrs9jg102malg09cnjdji7lkv9xxccpp3j9a41dfmpn330q80i"))))
|
| 72 | (build-system gnu-build-system)
|
| 73 | (native-inputs (list libpng lzip))
|
| 74 | (home-page "https://www.gnu.org/software/ocrad/")
|
| 75 | (synopsis "Optical character recognition based on feature extraction")
|
| 76 | (description
|
| 77 | "GNU Ocrad is an optical character recognition program based on a
|
| 78 | feature extraction method. It can read images in PBM, PGM or PPM formats and
|
| 79 | it produces text in 8-bit or UTF-8 formats.")
|
| 80 | (license license:gpl3+)))
|
| 81 |
|
| 82 | (define-public python-pytesseract
|
| 83 | (package
|
| 84 | (name "python-pytesseract")
|
| 85 | (version "0.3.13")
|
| 86 | (source
|
| 87 | (origin
|
| 88 | (method git-fetch)
|
| 89 | (uri (git-reference
|
| 90 | (url "https://github.com/madmaze/pytesseract")
|
| 91 | (commit (string-append "v" version))))
|
| 92 | (file-name (git-file-name name version))
|
| 93 | (sha256
|
| 94 | (base32 "16arn7ygk7ain5j5ayjcy10y6yhwfcc090i3r8q553m89rr1w0w1"))))
|
| 95 | (build-system pyproject-build-system)
|
| 96 | (arguments
|
| 97 | (list
|
| 98 | #:test-flags
|
| 99 | #~(map (lambda (name)
|
| 100 | (string-append "--deselect=tests/pytesseract_test.py::" name))
|
| 101 | |
| 102 | '("test_image_to_pdf_or_hocr[pdf]"
|
| 103 | "test_run_and_get_multiple_output[extensions0]"
|
| 104 | "test_run_and_get_multiple_output[extensions1]"))
|
| 105 | #:phases
|
| 106 | #~(modify-phases %standard-phases
|
| 107 | (add-after 'unpack 'set-tesseract-path
|
| 108 | (lambda* (#:key inputs #:allow-other-keys)
|
| 109 | (substitute* "pytesseract/pytesseract.py"
|
| 110 | (("tesseract_cmd = 'tesseract'")
|
| 111 | (format #f "tesseract_cmd = '~a'"
|
| 112 | (search-input-file inputs "/bin/tesseract"))))))
|
| 113 | (add-before 'check 'set-tessdata-prefix
|
| 114 | (lambda _
|
| 115 | (setenv "TESSDATA_PREFIX"
|
| 116 | |
| 117 | (string-append #$(this-package-native-input
|
| 118 | "tesseract-ocr-tessdata-fast")
|
| 119 | "/share/tessdata")))))))
|
| 120 | (native-inputs (list python-numpy
|
| 121 | python-packaging
|
| 122 | python-pandas
|
| 123 | python-pytest
|
| 124 | python-setuptools
|
| 125 | tesseract-ocr
|
| 126 | tesseract-ocr-tessdata-fast))
|
| 127 | (inputs (list tesseract-ocr))
|
| 128 | (propagated-inputs (list python-pandas python-pillow))
|
| 129 | (home-page "https://github.com/madmaze/pytesseract")
|
| 130 | (synopsis "Python wrapper for Google's Tesseract-OCR")
|
| 131 | (description
|
| 132 | "This package provides @command{pytesseract} and Python wrapper library
|
| 133 | for Google's Tesseract-@acronym{OCR, optical character recognition}.")
|
| 134 | (license license:asl2.0)))
|
| 135 |
|
| 136 | (define-public tesseract-ocr-tessdata-fast
|
| 137 | (package
|
| 138 | (name "tesseract-ocr-tessdata-fast")
|
| 139 | (version "4.1.0")
|
| 140 | (source (origin
|
| 141 | (method git-fetch)
|
| 142 | (uri (git-reference
|
| 143 | (url "https://github.com/tesseract-ocr/tessdata_fast")
|
| 144 | (commit version)))
|
| 145 | (file-name (git-file-name name version))
|
| 146 | (sha256
|
| 147 | (base32
|
| 148 | "1m310cpb87xx8l8q7jy9fvzf6a0m8rm0dmjpbiwhc2mi6w4gn084"))))
|
| 149 | (build-system copy-build-system)
|
| 150 | (arguments (list #:install-plan #~'(("." "share/tessdata"))
|
| 151 | #:phases #~(modify-phases %standard-phases
|
| 152 | (add-after 'unpack 'delete-broken-links
|
| 153 | (lambda _
|
| 154 | (delete-file "configs")
|
| 155 | (delete-file "pdf.ttf"))))))
|
| 156 | (home-page "https://github.com/tesseract-ocr/tessdata_fast")
|
| 157 | (synopsis "Fast integer versions of trained LSTM models")
|
| 158 | (description "This repository contains fast integer versions of trained
|
| 159 | models for the Tesseract OCR Engine.")
|
| 160 | (license license:asl2.0)))
|
| 161 |
|
| 162 | (define-public tesseract-ocr
|
| 163 | (package
|
| 164 | (name "tesseract-ocr")
|
| 165 | (version "5.3.0")
|
| 166 | (source
|
| 167 | (origin
|
| 168 | (method git-fetch)
|
| 169 | (uri (git-reference
|
| 170 | (url "https://github.com/tesseract-ocr/tesseract")
|
| 171 | (commit version)))
|
| 172 | (file-name (git-file-name name version))
|
| 173 | (sha256
|
| 174 | (base32
|
| 175 | "0vylcba8w5ljnr6pf3ilc2wjq72k660h71b7mlbjz3a2f0x5kr33"))))
|
| 176 | (build-system gnu-build-system)
|
| 177 | (arguments
|
| 178 | (list
|
| 179 | #:configure-flags
|
| 180 | #~(list (string-append "LIBLEPT_HEADERSDIR="
|
| 181 | #$(this-package-input "leptonica") "/include")
|
| 182 | "--disable-static") |
| 183 | |
| 184 | |
| 185 | #:tests? #f
|
| 186 | #:phases
|
| 187 | #~(modify-phases %standard-phases
|
| 188 | (add-after 'unpack 'do-not-override-xml-catalog-files
|
| 189 | (lambda _
|
| 190 | (substitute* "configure.ac"
|
| 191 | (("AC_SUBST\\(\\[XML_CATALOG_FILES])")
|
| 192 | ""))))
|
| 193 | (add-after 'build 'build-training
|
| 194 | (lambda* (#:key parallel-build? #:allow-other-keys)
|
| 195 | (define n (if parallel-build? (number->string
|
| 196 | (parallel-job-count))
|
| 197 | "1"))
|
| 198 | (invoke "make" "-j" n "training")))
|
| 199 | (add-after 'install 'install-training
|
| 200 | (lambda _
|
| 201 | (invoke "make" "training-install")))
|
| 202 | (add-after 'install 'install-minimal-tessdata
|
| 203 | |
| 204 | |
| 205 | |
| 206 | (lambda* (#:key native-inputs inputs #:allow-other-keys)
|
| 207 | (define eng.traineddata
|
| 208 | "/share/tessdata/eng.traineddata")
|
| 209 | (install-file (search-input-file (or native-inputs inputs)
|
| 210 | eng.traineddata)
|
| 211 | (dirname (string-append #$output
|
| 212 | eng.traineddata))))))))
|
| 213 | (native-inputs
|
| 214 | (list asciidoc
|
| 215 | autoconf
|
| 216 | automake
|
| 217 | curl
|
| 218 | docbook-xsl
|
| 219 | libarchive
|
| 220 | libtiff
|
| 221 | libtool
|
| 222 | libxslt
|
| 223 | pkg-config
|
| 224 | tesseract-ocr-tessdata-fast))
|
| 225 | (inputs
|
| 226 | (list cairo
|
| 227 | icu4c
|
| 228 | pango
|
| 229 | python-wrapper))
|
| 230 | (propagated-inputs
|
| 231 | |
| 232 | (list leptonica))
|
| 233 | (native-search-paths (list (search-path-specification
|
| 234 | (variable "TESSDATA_PREFIX")
|
| 235 | (files (list "share/tessdata"))
|
| 236 | (separator #f)))) |
| 237 | (home-page "https://github.com/tesseract-ocr/tesseract")
|
| 238 | (synopsis "Optical character recognition engine")
|
| 239 | (description
|
| 240 | "Tesseract is an optical character recognition (OCR) engine with very
|
| 241 | high accuracy. It supports many languages, output text formatting, hOCR
|
| 242 | positional information and page layout analysis. Several image formats are
|
| 243 | supported through the Leptonica library. It can also detect whether text is
|
| 244 | monospaced or proportional. Support for the English language is included by
|
| 245 | default. To add support for more languages, the
|
| 246 | @code{tesseract-ocr-tessdata-fast} package should be installed.")
|
| 247 | (license license:asl2.0)))
|
| 248 |
|
| 249 | (define-public gimagereader
|
| 250 | (package
|
| 251 | (name "gimagereader")
|
| 252 | (version "3.4.3")
|
| 253 | (source
|
| 254 | (origin
|
| 255 | (method url-fetch)
|
| 256 | (uri (string-append
|
| 257 | "https://github.com/manisandro/gImageReader/releases"
|
| 258 | "/download/v" version "/"
|
| 259 | "gimagereader-" version ".tar.xz"))
|
| 260 | (sha256
|
| 261 | (base32 "09f4njwhw7xkyq4pjzjrmypzczijckcbimwq8776hb4milzba126"))))
|
| 262 | (build-system qt-build-system)
|
| 263 | (arguments
|
| 264 | (list
|
| 265 | #:qtbase qtbase
|
| 266 | #:tests? #f |
| 267 | #:configure-flags #~(list "-DENABLE_VERSIONCHECK=0")))
|
| 268 | (native-inputs
|
| 269 | (list gettext-minimal intltool pkg-config))
|
| 270 | (inputs
|
| 271 | (list enchant
|
| 272 | djvulibre
|
| 273 | leptonica
|
| 274 | podofo
|
| 275 | poppler-qt6
|
| 276 | sane
|
| 277 | qtbase
|
| 278 | qt5compat
|
| 279 | qtspell
|
| 280 | qtwayland
|
| 281 | quazip
|
| 282 | tesseract-ocr))
|
| 283 | (home-page "https://github.com/manisandro/gImageReader")
|
| 284 | (synopsis "Qt front-end to tesseract-ocr")
|
| 285 | (description
|
| 286 | "gImageReader is a Qt front-end to Tesseract optical character
|
| 287 | recognition (OCR) software.
|
| 288 |
|
| 289 | gImageReader supports automatic page layout detection but the user can
|
| 290 | also manually define and adjust the recognition regions. It is
|
| 291 | possible to import images from disk, scanning devices, clipboard and
|
| 292 | screenshots. gImageReader also supports multipage PDF documents.
|
| 293 | Recognized text is displayed directly next to the image and basic text
|
| 294 | editing including search/replace and removing of line breaks is
|
| 295 | possible. Spellchecking for the output text is also supported if the
|
| 296 | corresponding dictionaries are installed.")
|
| 297 | (license license:gpl3+)))
|
| 298 |
|
| 299 | (define-public zinnia
|
| 300 | (let* ((commit "581faa8f6f15e4a7b21964be3a5ec36265c80e5b")
|
| 301 | (revision "1")
|
| 302 | |
| 303 | (version (git-version "0.07" revision commit)))
|
| 304 | (package
|
| 305 | (name "zinnia")
|
| 306 | (version version)
|
| 307 | (source
|
| 308 | (origin
|
| 309 | (method git-fetch)
|
| 310 | (uri (git-reference
|
| 311 | (url "https://github.com/taku910/zinnia")
|
| 312 | (commit commit)))
|
| 313 | (sha256
|
| 314 | (base32
|
| 315 | "1izjy5qw6swg0rs2ym2i72zndb90mwrfbd1iv8xbpwckbm4899lg"))
|
| 316 | (file-name (git-file-name name version))
|
| 317 | (modules '((guix build utils)
|
| 318 | (ice-9 ftw)
|
| 319 | (srfi srfi-26)))
|
| 320 | (snippet |
| 321 | '(begin
|
| 322 | (for-each delete-file-recursively
|
| 323 | (scandir "."
|
| 324 | (negate (cut member <> '("zinnia"
|
| 325 | "." "..")))))
|
| 326 | #t))))
|
| 327 | (build-system gnu-build-system)
|
| 328 | (arguments
|
| 329 | `(#:phases
|
| 330 | (modify-phases %standard-phases
|
| 331 | (replace 'bootstrap
|
| 332 | (lambda _
|
| 333 | (chdir "zinnia")
|
| 334 | (for-each make-file-writable
|
| 335 | '("config.log" "config.status"))
|
| 336 | #t)))))
|
| 337 | (home-page "https://taku910.github.io/zinnia/")
|
| 338 | (synopsis "Online hand recognition system with machine learning")
|
| 339 | (description
|
| 340 | "Zinnia is a simple, customizable and portable online hand recognition
|
| 341 | system based on Support Vector Machines. Zinnia simply receives user pen
|
| 342 | strokes as a sequence of coordinate data and outputs n-best characters sorted
|
| 343 | by SVM confidence. To keep portability, Zinnia doesn't have any rendering
|
| 344 | functionality. In addition to recognition, Zinnia provides training module
|
| 345 | that allows us to create any hand-written recognition systems with low-cost.")
|
| 346 | (license (list license:bsd-3 |
| 347 | (license:non-copyleft |
| 348 | "file://zinnia/aclocal.m4")
|
| 349 | license:x11 |
| 350 | license:public-domain))))) |
| 351 |
|
| 352 |
|