BSD 3-Clause "New" or "Revised" License

项目介绍

deajan/pmOCR 是一个托管在 GitHub 上的开源项目,主要使用 Shell 编写,采用 BSD 3-Clause "New" or "Revised" License 许可证,目前获得 66 个 Star、13 次 Fork。

仓库全名
deajan/pmOCR
开源许可证
BSD 3-Clause "New" or "Revised" License
Star 数
66
Fork 数
13
未关闭 Issue
2

README 摘要

pmOCR (poor man's OCR tool) This project has been archived ! It has been fun improving my bash skills while I begun coding this in like 2015. I initially planned to produce a better, python based version of this, but then I found OCRmyPDF project, which already does a great job ;) See https://github.com/ocrmypdf/OCRmyPDF for more info. If you're interested in Document Management Systems, also checkout paperless-ngx,…

完整内容见 GitHub 原始 README 或本页 。

常见问题

pmOCR 用什么语言开发?

主要使用 Shell 编写,采用 BSD 3-Clause "New" or "Revised" License 许可证,目前有 66 个 Star。

pmOCR 可以免费商用吗?

仓库采用 BSD 3-Clause "New" or "Revised" License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 pmOCR 的源码?

可以直接克隆仓库:git clone https://github.com/deajan/pmOCR.git,默认分支为 master;安装与运行步骤见仓库 README。

pmOCR 最近还在维护吗?

仓库最近一次更新为 2024年1月6日,当前有 2 个未关闭 Issue;Star 数为 66,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A wrapper for tesseract / abbyyOCR11 ocr4linux finereader cli that can perform batch operations or monitor a directory and launch an OCR conversion on file activity

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
93
价值分
43
活跃状态
归档

语言占比

Shell

贡献者

README

pmOCR (poor man’s OCR tool)

Build Status License GitHub Release

This project has been archived !

It has been fun improving my bash skills while I begun coding this in like 2015.
I initially planned to produce a better, python based version of this, but then I found OCRmyPDF project, which already does a great job ;)
See https://github.com/ocrmypdf/OCRmyPDF for more info.

If you’re interested in Document Management Systems, also checkout paperless-ngx, which is a fully open source, using OCRmyPDF.

Farewell, my old bash project.

pmOCR

A multicore batch & service wrapper script for Tesseract v3/v4/v5 (https://github.com/tesseract-ocr/) or ABBYY CLI OCR 11 FOR LINUX based on Finereader Engine 11 optical character recognition (www.ocr4linux.com).

Conversions support tiff/jpg/png/pdf/bmp to PDF, TXT and CSV (also DOCX and XSLX for Abbyy OCR). It can actually support any other format that your OCR engine can handle.

This wrapper can work both in batch and service mode.

In batch mode, it’s used as commandline tool for processing multiple files at once, being able to output one or more formats.

In service mode, it will monitor directories and launch OCR conversions as soon as new files get into the directories. Since v1.8.0, it can also monitor NFS / SMB mountpoints with new integrated inotifywait emulation poller.

pmOCR has the following options:

  • Include current date into the output filename
  • Ignore already OCRed PDF files based on font detection and / or file suffix
  • Delete or move input file after successful conversion

Install it

$ git clone https://github.com/deajan/pmOCR
$ cd pmOCR
$ ./install.sh

You will need pdffonts util (from poppler-utils package). Optionally, you can install inotifywait (from inotify-tools package).

If you are using tesseract OCR, please install tesseract-osd and tesseract-[your language] (sometimes called tesseract-ocr-osd). You will also need ImageMagick in order to be able to transform bitmap PDF documents to indexed PDFs.

Batch mode

Use pmocr to batch process all files in a given directory and its subdirectories.

Use --help for command line usage.

Example:

$ pmocr.sh --batch --target=pdf --skip-txt-pdf --delete-input /some/path
$ pmocr.sh --batch --target=pdf --target=csv --suffix=processed /some/path

If pmOCR wasn’t installed, you may run it directly with a configuration file like:

$ ./pmocr.sh --config=./default.conf --batch -p /some/path

OCR Configuration

pmOCR uses a default config stored in /etc/pmocr/default.conf You may change it’s contents or clone it and have pmOCR use an alternative configuration with:

$ pmocr.sh --config=/etc/pmocr/myConfig.conf --batch --target=csv /some/path

Service mode

Service mode monitors directories and their subdirectories and launched an OCR conversion whenever a new file is written. Keep in mind that only file creations are monitored. File moves aren’t.

pmocr is written to monitor up to 5 directories, each producing a different target format (PDF, DOCX, XLSX, TXT & CSV). Comment out a folder to disable it’s monitoring.

There’s also an option to avoid passing PDFs to the OCR engine that already contain text.

After installation, please configure /etc/pmocr/default.conf in order to monitor the directories you need, and adjust your specific options.

Launch service (initV style) service pmocr-srv start

Launch service (systemd style) systemctl start [email protected]

Check service state (initV style) service pmocr-srv status

Check service state (systemd style) systemctl status [email protected]

Multiple service instances

In order to monitor multiple directories with different OCR settings, you need to duplicate /etc/pmocr/default.conf configuration file. When launching pmOCR service with initV, each config file will create an instance. With systemD, you have to launch a service for each config file. Example for configs /etc/pmocr/default.conf and /etc/pmocr/other.conf

$ systemctl start [email protected]
$ systemctl start [email protected]

Support for OCR engines

Has been tested so far with:

  • ABBYY FineReader OCR Engine 11 CLI for Linux releases R2 (v 11.1.6.562411), R3 (v 11.1.9.622165) and R6 (v 11.1.14.707470)
  • Tesseract-ocr 3.0.4
  • Tesseract-ocr 4.0.0 and 4.0.12
  • Tesseract-ocr 5.0.0 and 5.0.1

Tesseract mode also uses ghostscript to convert PDF files to an intermediary TIFF format in order to process them.

It should virtually work with any engine as long as you adjust the parameters.

Parameters include any arguments to pass to the OCR program depending on the target format.

Support for OCR Preprocessors

ABBYY has in integrated preprocessor in order to enhance recognition qualitiy whereas Tesseract relies on external tools. pmOCR can use a preprocessor like ImageMagick to deskew / clear noise / render white background and remove black borders. ImageMagick preprocessor is configured, and enabled by default to be used with Tesseract.

Tesseract caveats

When no OSD / language data is installed, tesseract will still process documents, but the quality may suffer. While pmocr will warn you about this, the conversion still happens. Please make sure to install all necessary addons for tesseract.

Troubleshooting

Please check /var/log/pmocr.log or ./pmocr.log file for errors.

Filenames containing special characters should work, nevertheless, if your file doesn’t get converted, try to rename it and copy it again to the monitored directory or batch process it again.

By default, failing to prevent files will add a prefix ‘_OCR_ERR’ + date to the filename. In order to reprocess those files, the prefix has to be removed with the following command

$ find /monitor/path -iname "*_OCR_ERR.*" -print0 | xargs -0 -I {} sh -c 'export file="{}"; mv "$file" "${file//_OCR_ERR/}"'

If using tesseract to create searchable PDF files, please make sure to have version 3.03 or better installed.

评论

暂无评论