Tesseract ocr 输出在检测到的文本之间具有单个字符

Tesseract ocr output with single characters in between the detected text

我正在尝试使用 Tesseract 从下图中提取,

text = pytesseract.image_to_string(image, config='-c preserve_interword_spaces=1 --psm 1 --oem 1')

这是 tesseract 4 ocr 的结果,

print(text)

Wrote Datastream application 
e Used Kafka to get the accounts

如果你看到图像中的项目符号点被转换为e,我在文档中发现了几个这样的点被转换成ascii中的单个字符

如果有人熟悉此类问题并有解决方案,请告诉我。

我有一个建议,也许最好删除要点。

  • 删除要点的一种解决方案是应用adaptive-threshold

  • 如果我们将adaptive-threshold应用于当前图像:

  • 现在如果我们读它:

    • Wrote Datastream application |
      Used Kafka to get the accounts
      
      

代码:


import cv2
import pytesseract

img = cv2.imread("4XMue.png")
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
thr = cv2.adaptiveThreshold(gry, 255, cv2.ADAPTIVE_THRESH_MEAN_C,
                            cv2.THRESH_BINARY, 11, 131)
txt = pytesseract.image_to_string(thr)
print(txt)

请允许我告诉您,我的示例代码可能不适用于所有图像。由于图像可能有不同的伪影或需要额外的处理。您可能需要更改 adaptive-thresholdblock-sizeC 参数。因此,请先阅读 adaptive-threshold