【发布时间】:2021-11-06 21:48:18
【问题描述】:
我该如何纠正它?我已经尝试使用 lang="eng+equ" 参数来改善结果,但无济于事。
import cv2
import pytesseract
import numpy as np
img = cv2.imread("image.png")
img = cv2.resize(img, None, fx=1.2, fy=1.2, interpolation=cv2.INTER_CUBIC)
img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
img = cv2.threshold(img, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
img = cv2.bitwise_not(img)
kernel = np.ones((1, 1), np.uint8)
img = cv2.erode(img, kernel, iterations=1)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (1, 1))
img = cv2.dilate(img, kernel, iterations=1)
content = pytesseract.image_to_string(img, lang="eng+equ", config="--psm 13 -c tessedit_char_whitelist=0123456789+=")
print(content)
但 Tesseract 将其检测为 424 + 26 =
【问题讨论】:
-
如果你去搜索,会有很多结果,也许,tesseract 提高准确性 - 你从这些结果中尝试了什么?
-
我尝试使用 cv2 中的一些函数来提高图像质量...灰度、阈值、扩张、侵蚀,但我仍然没有很好的结果。我不知道我是否必须训练模型,因为图像看起来很简单。
-
tesseract 提高准确率的所有结果都可以尝试。
-
我在上面评论中指定的功能已经是我搜索的结果,以提高准确性。不过还是谢谢。
标签: python python-3.x ocr tesseract python-tesseract