How to build tesseract 4 beta on macOS

1
2
3
4
brew info tesseract

tesseract: stable 3.05.01 (bottled), HEAD
OCR (Optical Character Recognition) engine

The result of recognition on Chinese - Simplified is a little bit terrifying.
I noticed that it added a new neural network system based on LSTMs after 4.0.0+
But it need to be build from source code on macOS.
Thankfully, the manul is quit specify on their README.md

Install dependencies

1
2
3
4
5
brew install automake autoconf autoconf-archive libtool
brew install pkgconfig
brew install icu4c
brew install leptonica
brew install gcc

Compile

1
2
3
4
5
6
git clone https://github.com/tesseract-ocr/tesseract/
cd tesseract
./autogen.sh
./configure CC=gcc CXX=g++ CPPFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib
make -j
make install

Their best trained modes, download the language chi_sim.traineddata and put it under tesseract/4.0.0.1/tessdata/

Usage

1
2
tesseract image.png image -l chi_sim
cat image.txt

OK, it is still terrible under the Song typeface font. It need to be trained a new model by myself.


Finally, ignoring the tesseract, I found drag the image to OneNote, and Ctrl + Click -> Copy Text from Picture will get more Accuracy. 😓