DesignAssembler

備忘録に近い

tesseractを使う

tesseractはOCRツールです。

つまり、画像から文字を読み取ります。

tesseractのインストール

github.com

brewで提供されているのでbrewからインストール

$ brew install tesseract

簡単。

tesseractを使う

書式は以下のとおり

tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]

今回は以下の画像(tesseract.png)を使います。

f:id:hyottokoaloha:20160314092502p:plain

$ tesseract tesseract.png out

これでout.txtが生成されました。

out.txtの内容はこうなりました

Running Tesseract

Tesseract is a command-line program, so first open a terminal or command prompt. The

command is used like this:

tesseract imagename outputbase [—1 lang] [—psm pagesegmode] [configfile...]

80 basic usage to do OCR on an image called 'myscan.png' and save the result to 'out.txt' would
be:

tesseract myscan.png out

間違いは2箇所でしょうか。なかなかの精度ですね。

次はapi使ってc++から使います。