Skip to content

Instantly share code, notes, and snippets.

@adgaudio
Created February 21, 2018 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adgaudio/f772004444dc808e900c057d45f8b52e to your computer and use it in GitHub Desktop.
Save adgaudio/f772004444dc808e900c057d45f8b52e to your computer and use it in GitHub Desktop.
Install tesseract and leptonica from source
#!/usr/bin/env bash
# This script installs leptonica and tesseract from source
# it does not install other pre-requisites to a custom location.
# side note: install prefix is defined once per library.
# side note: it clones git repositories in the current directory.
set -e
set -u
# install leptonica
(
export INSTALL_PREFIX=~/.sources
git clone https://github.com/DanBloomberg/leptonica.git
mkdir leptonica/build ; cd leptonica/build
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DBUILD_PROG=1 ..
make -j8
make install
)
# install tesseract
(
export INSTALL_PREFIX=~/.sources
git clone https://github.com/tesseract-ocr/tesseract.git
mkdir tesseract/build ; cd tesseract/build
PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX ..
make -j8
make install
)
# install and test with tessdata
(
git clone https://github.com/tesseract-ocr/tessdata.git
tesseract --tessdata-dir ./tessdata -l heb ./tesseract/testing/hebrew.png out
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment