Skip to content

Commit 89c6dfd

Browse files
committed
add the OCR script.
1 parent 07f8bee commit 89c6dfd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ocr_core.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
try:
2+
from PIL import Image
3+
except ImportError:
4+
import Image
5+
import pytesseract
6+
7+
8+
def ocr_core(filename):
9+
"""
10+
This function will handle the core OCR processing of images.
11+
"""
12+
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
13+
return text # Then we will print the text in the image
14+
15+
16+
print("")
17+
print(ocr_core('images/ocr_image_1.png'))
18+
print("")

0 commit comments

Comments
 (0)