#author("2020-10-02T08:13:04+00:00","","")
#author("2021-01-23T07:37:59+00:00","","")
#topicpath


///////////////////////////////////////////////////////////////////////////////
* 目次 [#k4a7989e]
#contents();

///////////////////////////////////////////////////////////////////////////////
* tesseract-ocr [#tesseract-ocr]

//=============================================================================
** 環境構築 [#n9ab119f]
- debian の場合は以下をインストールする:
 tesseract-ocr
- 各国語毎の言語ファイルは別パッケージになっている。必要に応じて追加インストールする。
|~パッケージ              |~言語 |
|tesseract-ocr-ces      |チェコ語 |
|tesseract-ocr-jpn      |日本語 |
|tesseract-ocr-jpn-vert |日本語縦書き |
|tesseract-ocr-deu      |独逸語 |
|tesseract-ocr-deu-frak |独逸語フラクトゥール |
|tesseract-ocr-eng      |英語 |
|tesseract-ocr-fra      |仏語 |
|tesseract-ocr-all      |全ての言語 |
-- その他の言語については、[[debian.orgのページ>https://packages.debian.org/search?searchon=names&keywords=tesseract]] を参照。

//=============================================================================
** 実行 [#n793887d]
//-----------------------------------------------------------------------------
*** コマンドライン [#h22ada34]
    tesseract <input-image-file> <out-file> -l <lang> -psm <number>

//-----------------------------------------------------------------------------
*** option [#s1e08c32]
- <out-file>
-- 出力ファイル名。実際のファイル名はこの名前に更に ".txt" が付く。
- --tessdata-dir <path>
-- 言語データファイルの場所を <path> に指定する。
- --user-words <path-to-file>
-- ユーザ辞書ファイルとして <path-to-file> を指定する
- -c <var>=<val>
-- 設定値<var> の値を <val> にする
- -l <lang>
-- 使用言語を <lang> にする
-- jpn, ces, etc.,
- -psm <number>
- --psm <number>
-- Page segmentation modes:
--- 0 : Orientation and script detection (OSD) only.
 言語データ:osd.traineddata 必須
 OSD は Orientation and script detection の略
 言語の種類やテキストの傾斜角度等を xxxxx.osd に出力
--- 1 : Automatic page segmentation with OSD.
 言語データ:osd.traineddata 必須
 回転(90度・180度・270度)したテキストも認識する
--- 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.
 1文字として扱う。2文字以上ある場合は、すべてが誤認識する。
--- 11 : Sparse text. Find as much text as possible in no particular order.
 色の薄いテキスト。できるだけ多くのテキストを探す。
 デフォルトで探せなかったテキストも認識する。
--- 12 : Sparse text with OSD.
 言語データ:osd.traineddata 必須
 上記11番、及び、
 回転(90度・180度・270度)したテキストも認識する
--- 13 : Raw line. Treat the image as a single text line,
 bypassing hacks that are Tesseract-specific.


//=============================================================================
** 参考リンク [#na56b35d]
- [[Pythonで書くTesseract 4の基本的な使い方。APIとCLIからOCRを実行する方法>https://valmore.work/how-to-use-tesseract4-with-python/]]
- [[tesseract のオプション PSM をいじってみた | Binary Star>https://binary-star.net/tesseract-option-psm]]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS