OCR-based tool, used to feed OpenWines open-data, using wine bottle labels images:
These scripts use nodejs, dependencies are managed via npm
$ node wineocr.js etiquette_3.jpg
CHÂTEAU MERCIER
CÔTES DE BOURG
APPELLATION CÔTES DE BOURG CONTRÔLÉE
2000
15H ml
ÇERÊRÏfiLL MIS EN BOUTEILLE AU CHATEAU
“l |
S.C.E.A. FAMILLE CHETY, PRODUCTEUR A SA|NT—TROJAN (GIRONDE) FRANCE .
The OCR output is both displayed in the console and written in a newly created [IMAGE_PATH].ocr.txt
file
$ node wineocr.js [path] [layout_analysis_option] [language_code]
$ node wineocr.js ./examples/etiquette_3.jpg
which is the equivalent of the default options:
$ node wineocr.js examples/etiquette_3.jpg 3 fra
Argument details:
- both directory and single file path work, as first argument
3
is a layout analysis option fortesseract
OCRfra
is a language code. Available languages depend on your tesseract installation (see below).
Note that you can either process a whole directory:
$ node wineocr.js examples/
tesseract is an open-source project and a madatory dependency for WineOCR.
For Mac OS X:
brew install tesseract --all-languages
For other OS as Windows or GNU/Linux, and details about installing only certain languages packs, check out the tesseract-ocr Project website.
npm install
layout_analysis_option
argument (see psm
argument in node-tesseract
lib) tells Tesseract OCR binary to only run a subset of layout analysis and assume a certain form of image. The options are:
- 0 = Orientation and script detection (OSD) only.
- 1 = Automatic page segmentation with OSD.
- 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.
3
seems to be a good option for most wine bottle labels.
MIT License - See license file.
Sources are available at OpenWines/WineOCR on Github.
Please check OpenWines/WineOCR/issues page on Github.