1try:
2 from PIL import Image
3except ImportError:
4 import Image
5import pytesseract
6
7def ocr_core(filename):
8 """
9 This function will handle the core OCR processing of images.
10 """
11 text = pytesseract.image_to_string(Image.open(filename)) # We'll use Pillow's Image class to open the image and pytesseract to detect the string in the image
12 return text
13
14print(ocr_core('images/ocr_example_1.png'))
15