Skip to content
gcv2hocr converts from Google Cloud Vision OCR output to hocr to make a searchable pdf.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample
.gitignore Makefile to compile/install, updated README, gitignore Sep 11, 2016
Makefile
README.md Improved XML character replacement Feb 28, 2019
gcv2hocr.py
gcvocr.sh Added languageHints option Oct 23, 2017
main.c Improved XML character replacement Feb 28, 2019
makepdf.sh fixed warning about &lang and output pdf name as out.pdf. Nov 11, 2017
test.sh

README.md

gcv2hocr

gcv2hocr converts from Google Cloud Vision OCR output to hocr to make a searchable pdf.

Installation

Compile:

make

Install to /usr/local/bin:

make install

Install to $HOME/.local/bin:

make install PREFIX=$HOME/.local

Uninstall:

make uninstall

Usage

gcv2hocr test.jpg.json output.hocr

test.jpg.json is a output of Google Cloud Vision OCR. output.hocr is a output of gcv2hocr.

You may specify image size in argument.

gcv2hocr test.jpg.json output.hocr 1280 960

First number 1280 is image height of the picture. Second number 960 is image width of the picture.

gcv2hocr also generates intermediary files preout1.txt and preout2.txt.

You may use gcv2hocr.py instead of gcv2hocr executable.

python gcv2hocr.py test.jpg.json > output.hocr

--savefile (python only) if defined will output to file instead of console.

How to get OCR (json) data:

Execute gcvocr.sh.

./gcvocr.sh test.jpg "Your API KEY"

gcvocr.sh is slightly modified sample.sh originally written by Kazuhiro FURUHATA (openspc@alpha.ocn.ne.jp).

How to make a searchable pdf:

To create a searchable pdf, use the hocr-pdf script bundled with hocr-tools.

makepdf.sh is a sample shell script to make a searchable pdf from individual jpeg files.

Acknowledgments

To Kazuhiro FURUHATA, he gave me a permission redistribute and modify sample.sh.

To Philipp Zumstein, he gave me answers several questions about hocr.

To Konstantin Baierer, he wrote python port (gcv2hocr.py).

To skylord123, he fixed many bugs in python port.

To URIN HACK, he gave me a permission redistribute his replace() code. (http://urin.github.io/posts/2018/replace-string-by-c-lang)

Licence

Creative Commons Attribution 4.0 International.

You are free to:

    Share — copy and redistribute the material in any medium or format
    Adapt — remix, transform, and build upon the material
    for any purpose, even commercially.

    The licensor cannot revoke these freedoms as long as you follow the license terms.

2016.9.2 ENDO Michiaki (inugami.mamoru@gmail.com)

You can’t perform that action at this time.