【问题标题】:Tesseract confuses + (plus sign) with 4 in simple equationsTesseract 在简单方程中将 +(加号)与 4 混淆
【发布时间】: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


【解决方案1】:

这是整个图像,还是图像的子集?如果是后者,那可能是你的问题。

我发现 PyTess 可以提供不同的结果,具体取决于它是一个整体还是图像的子集。

【讨论】:

  • 这是整个图像!
猜你喜欢
  • 2018-01-06
  • 1970-01-01
  • 1970-01-01
  • 2014-01-20
  • 2013-11-15
  • 1970-01-01
  • 2013-03-22
  • 1970-01-01
  • 2016-04-01
相关资源
最近更新 更多