feat: tesseract 单字母识别
This commit is contained in:
parent
723d5dcb74
commit
bf4cd8d028
16
ocr.py
16
ocr.py
|
@ -4,7 +4,7 @@ import numpy as np
|
|||
from pytesseract import Output
|
||||
|
||||
# img_source = cv2.VideoCapture(0)
|
||||
img_source = cv2.imread('./coffee-ocr.jpg')
|
||||
img_source = cv2.imread('./img.png')
|
||||
|
||||
|
||||
def get_grayscale(image):
|
||||
|
@ -51,4 +51,16 @@ def test_performance():
|
|||
cv2.imshow('img', img)
|
||||
cv2.waitKey(0)
|
||||
|
||||
print(pytesseract.image_to_data(img_source, output_type=Output.DICT)['text'])
|
||||
# print(pytesseract.image_to_data(img_source, output_type=Output.DICT)['text'])
|
||||
|
||||
def identy_char(img_path):
|
||||
source_img = cv2.imread(img_path)
|
||||
d = pytesseract.image_to_data(source_img, output_type=Output.DICT, config='--psm 10')
|
||||
|
||||
for text in d['text']:
|
||||
# print(text)
|
||||
if len(text) == 1 and text.isalpha():
|
||||
print(text)
|
||||
|
||||
if __name__ == "__main__":
|
||||
identy_char('./img.png')
|
Loading…
Reference in New Issue