I installed pytesseract via pip and its result is terrible.
有时需要对输入图像进行预处理以获得准确的结果
Because large and clear test images work fine, I think it is a problem about lack of data. But any other possible solution is welcomed as long as it can read text with Python.
import cv2
from pytesseract import image_to_string
img = cv2.imread("6Celp.jpg")
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
opn = cv2.morphologyEx(gry, cv2.MORPH_OPEN, None)
txt = image_to_string(opn)
txt = txt.split("\n")
for i in txt:
i = i.strip()
if i != '' and len(i) > 3:
print(i)
有时需要对输入图像进行预处理以获得准确的结果
你可以说缺乏数据是一个问题。我想你会发现morphological-transformations很有用
例如,如果我们应用
close
操作,结果将是:该图像看起来与原始发布的图像相似。但是,输出图像中有轻微变化(即语法单词与原始图像略有不同)
现在,如果我们读取输出图像:
代码:
相关问题 更多 >
编程相关推荐