Tesseract OCR で画像から日本語の文字認識する [macOS 編]
macOS にて OSS ツール Tesseract OCR で画像から日本語の文字認識する方法をご紹介します。
背景 日本語 OCR 対応の OSS ツール
日本語 OCR 対応の OSS ツールを探していて、第577回 Tesseract OCRで文字認識をする | gihyo.jp の記事を読んで Tesseract OCR が良さそうだったので、使ってみました。
Tesseract の初期設定
Tesseract の初期設定として、インストール、日本語の学習済みモデルのファイルのダウンロードを順番におこないます。
Tesseract のインストール
brew install tesseract
日本語の学習済みモデルのファイルをダウンロード
cd /opt/homebrew/share/tessdata/
wget https://github.com/tesseract-ocr/tessdata/raw/main/jpn.traineddata
wget https://github.com/tesseract-ocr/tessdata/raw/main/jpn_vert.traineddata
- ダウンロード元: tesseract-ocr/tessdata: Trained models with fast variant of the "best" LSTM models + legacy models
Tesseract で日本語の OCR
tesseract target.png - -l jpn
以上、Tesseract OCR で画像から日本語の文字認識した、現場からお送りしました。