-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathocr2.py
More file actions
25 lines (16 loc) · 697 Bytes
/
ocr2.py
File metadata and controls
25 lines (16 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def ocr(img):
import cv2
import pytesseract
#from matplotlib import pyplot as plt
# Uncomment the line below to provide path to tesseract manuall
pytesseract.pytesseract.tesseract_cmd ='C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
# Define config parameters.
# '-l eng' for using the English language
# '--oem 1' for using LSTM OCR Engine
config = ('-l eng --oem 1 --psm 3')
# Our operations on the frame come here
#gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Run tesseract OCR on image
text = pytesseract.image_to_string(img, config=config)
# Print recognized text
return (text)