Adobe scanとTesseract OCRを組み合わせて自炊する。

非破壊で本を自炊しようとした際に、文字認識(OCR)に結構困る。

今回はOCRにOCRmyDPFTesseract OCRを用いる。

# Tesseract OCR、OCRmyPDFとは

https://github.com/tesseract-ocr/tesseract

1
Tesseract was originally developed at Hewlett-Packard Laboratories Bristol UK and at Hewlett-Packard Co, Greeley Colorado USA between 1985 and 1994, with some more changes made in 1996 to port to Windows, and some C++izing in 1998. In 2005 Tesseract was open sourced by HP. From 2006 until November 2018 it was developed by Google
1
Tesseractは元々、1985年から1994年にかけて、イギリスのヒューレット・パッカード研究所(Hewlett-Packard Laboratories Bristol UK)と、アメリカのコロラド州グリーリーのヒューレット・パッカード社(Hewlett-Packard Co, Greeley Colorado USA)で開発された。2005年、TesseractはHPによってオープンソース化された。2006年から2018年11月まではGooglによって開発されていた。

というOCRソフト

これをPDFでより扱いやすいようにしてくれているのがOCRmyPDF

https://github.com/ocrmypdf/OCRmyPDF

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
I searched the web for a free command line tool to OCR PDF files: I found many, but none of them were really satisfying:

Either they produced PDF files with misplaced text under the image (making copy/paste impossible)
Or they did not handle accents and multilingual characters
Or they changed the resolution of the embedded images
Or they generated ridiculously large PDF files
Or they crashed when trying to OCR
Or they did not produce valid PDF files
On top of that none of them produced PDF/A files (format dedicated for long time storage)
...so I decided to develop my own tool.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
PDFファイルをOCRするフリーのコマンドラインツールをウェブで探した:たくさん見つけたが、どれも満足できるものではなかった:

画像の下のテキストの位置がずれている(コピー・ペーストが不可能)PDFファイルが生成される。
アクセント記号や多言語文字を扱えない。
埋め込み画像の解像度を変えてしまう
とんでもなく大きなPDFファイルを生成する
OCRしようとするとクラッシュする
有効なPDFファイルを生成しない
その上、PDF/Aファイル(長期保存専用フォーマット)を生成するものもなかった。
そこで、私は独自のツールを開発することにしました。

ということらしい。

細かい使い方は先人の方が素晴らしい資料を残してくださっているので、そちらを参照

https://gihyo.jp/admin/serial/01/ubuntu-recipe/0770

今回はAdobe scanで書類をとってOCRmyPDFで文字認識をする。

# Adobe scan

Adobe scanの記事はこちら

この記事ではAdobeのOCRを活用しているが、本を自炊する際にはAdobe scanでは一度に25枚までしかOCRできないことが問題になる。一応課金すれば100枚まではできるようになるが、結構高い。

Adobe scanでは書類を撮る際には無料版でも100枚まで取れるので、これを利用する。

# やり方

1.書籍モードで100ページごとに撮る 2.Adobe cloudに上がるので、PCでログインし、必要なファイルをダウンロード 3.OCrmyPDF でOCRをかける。 4.PDFを結合させて完成!

# 終わりに

Adobeで25枚ずつOCRさせてもいいのだが、最近AdobeのOCRが遅いので、100枚まとめて自分のPCで処理させたほうが便利だったりする。

研究室の一角 - にほんブログ村

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Hugo で構築されています。
テーマ StackJimmy によって設計されています。