web-dev-qa-db-ja.com

Windowsコマンドラインでtesseractocrをテストできますか?

私はtesseractOCRを初めて使用します。画像をtifに変換して実行し、Windowsでcmdを使用してtesseractからの出力を確認しようとしましたが、できませんでした。手伝って頂けますか?使用するコマンドは何ですか?

これが私のサンプル画像です:

enter image description here

8
Akunar

最も単純なtesseract.exe構文はtesseract.exe inputimage output-text-fileです。ここでの前提は、tesseract.exeがPATH環境変数に追加されることです。テキスト引数が特に認識しにくい場合は、-psm N引数を追加できます。

精度のレベルが十分でない場合を除いて、通常の構文(-psmスイッチなし)は、添付した画像で十分に機能することがわかります。

英語以外の文字(処方箋の横の記号など)は認識されないことに注意してください。私のデフォルトのインストールには、英語のトレーニングデータのみが含まれています。

Tesseract構文の説明は次のとおりです。

C:\Users\vish\Desktop>tesseract.exe
Usage:tesseract.exe imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]

pagesegmode values are:
0 = Orientation and script detection (OSD) only.
1 = Automatic page segmentation with OSD.
2 = Automatic page segmentation, but no OSD, or OCR
3 = Fully automatic page segmentation, but no OSD. (Default)
4 = Assume a single column of text of variable sizes.
5 = Assume a single uniform block of vertically aligned text.
6 = Assume a single uniform block of text.
7 = Treat the image as a single text line.
8 = Treat the image as a single Word.
9 = Treat the image as a single Word in a circle.
10 = Treat the image as a single character.
-l lang and/or -psm pagesegmode must occur before anyconfigfile.

Single options:
  -v --version: version info
  --list-langs: list available languages for tesseract engine

そして、これがあなたの画像の出力です(注:ダウンロードすると、PNG画像に変換されます)。

C:\Users\vish\Desktop>tesseract.exe ECL8R.png out.txt
Tesseract Open Source OCR Engine v3.02 with Leptonica

C:\Users\vish\Desktop>type out.txt.txt
1 Project Background

A prescription (R) is a written order by a physician or medical doctor to a pharmacist in the form of
medication instructions for an individual patient. You can't get prescription medicines unless someone
with authority prescribes them. Usually, this means a written prescription from your doctor. Dentists,

optometrists, midwives and nurse practitioners may also be authorized to prescribe medicines for you.

It can also be defined as an order to take certain medications.

A prescription has legal implications; this means the prescriber must assume his responsibility for the
clinical care ofthe patient.

Recently, the term "prescriptionΓÇ¥ has known a wider usage being used for clinical assessments,
16
Vish