154.5. tesseract-5.5.3
OCR engine — text from scanned images
5.5.3-1 · Apache-2.0 · 2.0 SBU · 5.1 MiB, 57 files · 41_system, 856 of 1047 · ports/core/printing/tesseract
Homepage: https://github.com/tesseract-ocr/tesseract
Tesseract is the optical character recognition (OCR) engine: it reads the text in a scanned or photographed page. It installs the tesseract command and the libtesseract library that skanpage and gimagereader recognise text with. It recognises a language only when that language’s trained data is installed; tessdata-eng provides English.
Depends on: cmake, ninja, pkgconf, leptonica, libarchive, curl, icu, libtiff, asciidoctor, tessdata-eng.
Required by (6): ffmpeg, gimagereader, mupdf, ocrmypdf, skanpage, spectacle.
Sources: tesseract-5.5.3.tar.gz (1.8 MiB). Every step kpkg takes applies to this port.
Install: script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install tesseract'
build.sh:
mkdir -p build && cd build
cmake .. -G Ninja \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TRAINING_TOOLS=OFF \
-DDISABLE_TIFF=OFF \
-DDISABLE_ARCHIVE=OFF \
-DDISABLE_CURL=OFF \
-DGRAPHICS_DISABLED=ON \
-DUSE_SYSTEM_ICU=ON \
-DTESSDATA_PREFIX=/usr/share
for def in HAVE_TIFFIO_H HAVE_LIBARCHIVE HAVE_LIBCURL TESSDATA_PREFIX; do
grep -q "^#define $def " config_auto.h || { echo "tesseract: $def not configured" >&2; exit 1; }
done
ninja
DESTDIR=$PKG ninja install
mkdir -p man
for page in tesseract.1 unicharset.5; do
asciidoctor -b manpage -o man/$page ../doc/$page.asc
install -Dm644 man/$page -t "$PKG/usr/share/man/man${page##*.}"
done
-DTESSDATA_PREFIX=/usr/share— The directory whosetessdataholds the language files, compiled into the library throughconfig_auto.h. The autotools build defines it fromdatadir; the CMake build defines it only when this is passed, and the library otherwise looks for its languages in./, so withTESSDATA_PREFIXunset in the environmenttesseract --list-langslists none and gImageReader has no language to recognise. After the configure,build.shchecksconfig_auto.hfor this define and for the libtiff, libarchive and curl ones, and stops if any is missing.-DGRAPHICS_DISABLED=ON— Compile out ScrollView, the debugging display that opens a TCP connection to a separate Java viewer,ScrollView.jar, to draw the page analysis. The CMake build does not build that viewer and nothing in the tree ships it.
Programs: tesseract.
Libraries: libtesseract.so.
Directories: /usr/include/tesseract, /usr/lib/cmake/tesseract, /usr/share/licenses/tesseract, /usr/share/tessdata/configs, /usr/share/tessdata/tessconfigs.