-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtess.py
38 lines (30 loc) · 1.29 KB
/
tess.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
from modules import *
pytesseract.pytesseract.tesseract_cmd = '../../utils/tesseract/tesseract'
def reconize(image):
image = np.asarray(image)
phrase = pytesseract.image_to_string(image, lang='eng')
phrase = pytesseract.image_to_string(image, config="-c tessedit"
"_char_whitelist=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
" -l osd"
" ")
return phrase
def recognizeFromLetters(letters):
result = ""
for letter in letters:
letter = np.asarray(letter)
phrase = pytesseract.image_to_string(letter, config="-c tessedit"
"_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
" --psm 10"
" -l osd"
" ")
cv2.imshow('image',letter)
cv2.waitKey(0)
cv2.destroyAllWindows()
#phrase = pytesseract.image_to_string(letter, lang='eng')
# phrase = pytesseract.image_to_string(letter, config="-c tessedit"
# "_char_whitelist=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
# " -l osd"
# " ")
print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:',phrase)
result = result + phrase
return result