Tesseract OCR Engine
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
import pytesseract | |
import requests | |
from PIL import Image | |
from PIL import ImageFilter | |
from StringIO import StringIO | |
def process_image(url): | |
image = _get_image(url) | |
# image = image.resize( [int(2 * s) for s in image.size] ) | |
# image.filter(ImageFilter.SHARPEN) | |
# image.filter(ImageFilter.EDGE_ENHANCE) | |
# image.filter(ImageFilter.FIND_EDGES) | |
return pytesseract.image_to_string(image) | |
def _get_image(url): | |
return Image.open(StringIO(requests.get(url).content)) | |
# edit 5/12/16: image filters and resizing needs to be tested to see what works best. | |
# adapted from https://realpython.com/blog/python/setting-up-a-simple-ocr-server/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yay that works! Thanks Sarah!