-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from UB-Mannheim/new
Merge changes by UB-Mannheim
- Loading branch information
Showing
23 changed files
with
370 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/venv | ||
/*_venv | ||
/build/ | ||
/dist/ | ||
/*.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,174 @@ | ||
# About | ||
# hocr-tools | ||
|
||
hOCR is a format for representing OCR output, including layout information, character confidences, bounding boxes, and style information. It embeds this information invisibly in standard HTML. By building on standard HTML, it automatically inherits well-defined support for most scripts, languages, and common layout options. Furthermore, unlike previous OCR formats, the recognized text and OCR-related information co-exist in the same file and survives editing and manipulation. hOCR markup is independent of the presentation. | ||
* [About](#about) | ||
* [About the code](#about-the-code) | ||
* [Pointers](#pointers) | ||
* [Installation](#installation) | ||
* [System-wide](#system-wide) | ||
* [Virtualenv](#virtualenv) | ||
* [Available Programs](#available-programs) | ||
* [hocr-check](#hocr-check) -- check the hOCR file for errors | ||
* [hocr-combine](#hocr-combine) -- combine pages in multiple hOCR files into a single document | ||
* [hocr-eval](#hocr-eval) -- compute number of segmentation and OCR errors | ||
* [hocr-eval-geom](#hocr-eval-geom) -- compute over, under, and mis-segmentations | ||
* [hocr-eval-lines](#hocr-eval-lines) -- compute OCR errors of hOCR output relative to text ground truth | ||
* [hocr-extract-g1000](#hocr-extract-g1000) -- extract lines from Google 1000 book sample | ||
* [hocr-extract-images](#hocr-extract-images) -- extract the images and texts within all the ocr_line elements | ||
* [hocr-lines](#hocr-lines) -- extract the text within all the ocr_line elements | ||
* [hocr-merge-dc](#hocr-merge-dc) -- merge Dublin Core meta data into the hOCR HTML header | ||
* [hocr-pdf](#hocr-pdf) -- create a searchable PDF from a pile of hOCR and JPEG | ||
* [hocr-split](#hocr-split) -- split an hOCR file into individual pages | ||
|
||
## About | ||
|
||
hOCR is a format for representing OCR output, including layout information, | ||
character confidences, bounding boxes, and style information. | ||
It embeds this information invisibly in standard HTML. | ||
By building on standard HTML, it automatically inherits well-defined support | ||
for most scripts, languages, and common layout options. | ||
Furthermore, unlike previous OCR formats, the recognized text and OCR-related | ||
information co-exist in the same file and survives editing and manipulation. | ||
hOCR markup is independent of the presentation. | ||
|
||
There is a [Public Specification](http://docs.google.com/View?docid=dfxcv4vc_67g844kf) for the hOCR Format. | ||
|
||
# Available Programs | ||
### About the code | ||
|
||
Each command line program is self contained; if you have the right | ||
Python packages installed, it should just work. (Unfortunately, that | ||
means some code duplication; we may revisit this issue in later | ||
revisions.) | ||
|
||
### Pointers | ||
|
||
The format itself is defined here: | ||
|
||
http://docs.google.com/View?docID=dfxcv4vc_67g844kf&revision=_latest | ||
|
||
## Installation | ||
|
||
### System-wide | ||
|
||
On a Debian/Ubuntu system, install the dependencies from packages: | ||
|
||
``` | ||
sudo apt-get install python-lxml python-reportlab python-pil \ | ||
python-beautifulsoup python-numpy python-scipy python-matplotlib | ||
``` | ||
|
||
Or, to fetch dependencies from the [cheese shop](https://pypi.python.org/pypi): | ||
|
||
``` | ||
sudo pip install -r requirements.txt # basic | ||
``` | ||
|
||
Then install the dist: | ||
|
||
``` | ||
sudo python setup.py install | ||
``` | ||
|
||
### Virtualenv | ||
|
||
Once | ||
|
||
``` | ||
virtualenv venv | ||
source venv/bin/activate | ||
pip install -r requirements.txt | ||
``` | ||
|
||
Subsequently | ||
|
||
``` | ||
source venv/bin/activate | ||
./hocr-... | ||
``` | ||
|
||
## Available Programs | ||
|
||
Included command line programs: | ||
|
||
* hocr-check -- check the hOCR file for errors | ||
* hocr-combine -- combine pages in multiple hOCR files into a single document | ||
* hocr-eval -- compute number of segmentation and OCR errors | ||
* hocr-eval-geom -- compute over, under, and mis-segmentations | ||
* hocr-eval-lines -- compute OCR errors of hOCR output relative to text ground truth | ||
* hocr-extract-images -- extract the images and texts within all the ocr_line elements | ||
* hocr-lines -- extract the text within all the ocr_line elements | ||
* hocr-pdf -- create a searchable PDF from a pile of hOCR and JPEG | ||
* hocr-split -- split an hOCR file into individual pages | ||
* hocr-merge-dc -- merge Dublin Core meta data into the hOCR HTML header | ||
### hocr-check | ||
|
||
``` | ||
hocr-check file.html | ||
``` | ||
|
||
Perform consistency checks on the hOCR file. | ||
|
||
### hocr-combine | ||
|
||
``` | ||
hocr-combine file1.html file2.html... | ||
``` | ||
|
||
Combine the OCR pages contained in each HTML file into a single document. | ||
The document metadata is taken from the first file. | ||
|
||
### hocr-eval-lines | ||
|
||
``` | ||
hocr-eval-lines [-v] true-lines.txt hocr-actual.html | ||
``` | ||
|
||
Evaluate hOCR output against ASCII ground truth. This evaluation method | ||
requires that the line breaks in true-lines.txt and the ocr_line elements | ||
in hocr-actual.html agree (most ASCII output from OCR systems satisfies this | ||
requirement). | ||
|
||
### hocr-eval-geom | ||
|
||
``` | ||
hocr-eval-geom [-e element-name] [-o overlap-threshold] hocr-truth hocr-actual | ||
``` | ||
|
||
Compare the segmentations at the level of the element name (default: ocr_line). | ||
Computes undersegmentation, oversegmentation, and missegmentation. | ||
|
||
### hocr-eval | ||
|
||
``` | ||
hocr-eval hocr-true.html hocr-actual.html | ||
``` | ||
|
||
Evaluate the actual OCR with respect to the ground truth. This outputs | ||
the number of OCR errors due to incorrect segmentation and the number | ||
of OCR errors due to character recognition errors. | ||
|
||
It works by aligning segmentation components geometrically, and for each | ||
segmentation component that can be aligned, computing the string edit distance | ||
of the text the segmentation component contains. | ||
|
||
### hocr-extract-g1000 | ||
|
||
Extract lines from [Google 1000 book sample](http://commondatastorage.googleapis.com/books/icdar2007/README.txt) | ||
|
||
### hocr-extract-images | ||
|
||
TODO | ||
|
||
### hocr-lines | ||
|
||
TODO | ||
|
||
### hocr-merge-dc | ||
|
||
``` | ||
hocr-merge-dc dc.xml hocr.html > hocr-new.html | ||
``` | ||
|
||
Merges the Dublin Core metadata into the hOCR file by encoding the data in its header. | ||
|
||
### hocr-pdf | ||
|
||
TODO | ||
|
||
### hocr-split | ||
|
||
``` | ||
hocr-split file.html pattern | ||
``` | ||
|
||
Split a multipage hOCR file into hOCR files containing one page each. | ||
The pattern should something like "base-%03d.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.