技術メモ

Scala,React Nativaなどの技術メモ

OCRやってみる

世間は大晦日だが、実家にも帰らず納豆食べてる。

Googleのtesseract-ocrを使ってみる。

github.com

とりあえずサンプリをローカルで動かしてみたい。 いきなりの

./autogen.sh: line 60: aclocal: command not found
brew install autoconf
brew install automake

さらに、

./autogen.sh: line 65: libtoolize: command not found
./autogen.sh: line 65: glibtoolize: command not found
brew install libtool

またまた、

checking for leptonica... configure: error: leptonica not found
brew install leptonica
CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure

インストールが完了。

% tesseract input/test1.png output
Tesseract Open Source OCR Engine v3.05.00dev with Leptonica
Error opening data file /Users/papua/Documents/source/c/tesseract/tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
Could not initialize tesseract.

言語ファイルを落としてきてリトライする。全部落とすと2GBくらいになるので注意。

github.com

うまくいけた。

f:id:papuaaaaaaa:20151231192047p:plain

かけ さろ 竈玉 レつぽ〈
アツアツ ヒヤヒヤ 天ぶら

かけ ざる 釜玉 しっぽく
アツァツ ヒヤヒヤ 天ぷら

一年前よりも精度は大分よくなってるぽい。

iti.hatenablog.jp