Commit 7b20fe0a authored by Paulo Miguel Almeida's avatar Paulo Miguel Almeida

Improved formatting on README

parent a8c288ff
......@@ -14,43 +14,43 @@ bmp, tiff, and others. It also support bounding box data.
## Usage
from PIL import Image
import sys
import pyocr
import pyocr.builders
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
tool = tools[0]
print("Will use tool '%s'" % (tool.get_name()))
# Ex: Will use tool 'tesseract'
langs = tool.get_available_languages()
print("Available languages: %s" % ", ".join(langs))
lang = langs[0]
print("Will use lang '%s'" % (lang))
# Ex: Will use lang 'fra'
txt = tool.image_to_string(Image.open('test.png'),
lang=lang,
builder=pyocr.builders.TextBuilder())
word_boxes = tool.image_to_string(Image.open('test.png'),
lang=lang,
builder=pyocr.builders.WordBoxBuilder())
line_and_word_boxes = tool.image_to_string(
Image.open('test.png'), lang=lang,
builder=pyocr.builders.LineBoxBuilder())
# Digits - Only Tesseract
digits = tool.image_to_string(Image.open('test-digits.png'),
```Python
from PIL import Image
import sys
import pyocr
import pyocr.builders
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
tool = tools[0]
print("Will use tool '%s'" % (tool.get_name()))
# Ex: Will use tool 'tesseract'
langs = tool.get_available_languages()
print("Available languages: %s" % ", ".join(langs))
lang = langs[0]
print("Will use lang '%s'" % (lang))
# Ex: Will use lang 'fra'
txt = tool.image_to_string(Image.open('test.png'),
lang=lang,
builder=pyocr.builders.TextBuilder())
word_boxes = tool.image_to_string(Image.open('test.png'),
lang=lang,
builder=pyocr.tesseract.DigitBuilder())
builder=pyocr.builders.WordBoxBuilder())
line_and_word_boxes = tool.image_to_string(
Image.open('test.png'), lang=lang,
builder=pyocr.builders.LineBoxBuilder())
# Digits - Only Tesseract
digits = tool.image_to_string(Image.open('test-digits.png'),
lang=lang,
builder=pyocr.tesseract.DigitBuilder())
```
## Dependencies
* PyOCR requires python 2.7 or later.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment