繁体   English   中英

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

[英]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参数。 因此,请从阅读自适应阈值开始

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM