【问题标题】:Tesseract: problems with upper-case characterTesseract:大写字符的问题
【发布时间】:2019-09-18 07:39:03
【问题描述】:

我将 Tesseract 与 Python 一起使用。我有一张包含 1-6 个字的图片,需要阅读文字。有时,在大小写中看起来相同的字符“C”被检测为小写 c 而不是大写 C。我看到了问题,但在以下字母的上下文中,应该可以检测到正确的符号.有什么配置或什么可以改进吗?我正在使用此代码

import pytesseract
import argparse
import cv2
import os

# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
    help="path to input image to be OCR'd")
args = vars(ap.parse_args())

# load the example image and convert it to grayscale
image = cv2.imread(args["image"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# write the grayscale image to disk as a temporary file so we can
# apply OCR to it
filename = "{}.png".format(os.getpid())
cv2.imwrite(filename, gray)

# load the image as a PIL/Pillow image, apply OCR, and then delete
# the temporary file
text = pytesseract.image_to_string(gray)
print("Output: " + text)

我查看了 config='-psm x' 的配置选项,其中 x 具有不同的值,但没有适合我的问题

【问题讨论】:

  • 您可能需要对图像进行预处理,以使用形态学操作来平滑/去除噪点。你能添加你的输入图像吗?

标签: python tesseract python-tesseract


【解决方案1】:

从 Tesseract 3 更新到 Tesseract 5 解决了这个问题

【讨论】:

  • 遇到同样的问题,关于您使用了哪个版本的 Tesseract 的任何提示,或者在哪里可以找到它?你自己编译过吗?谢谢!
猜你喜欢
  • 2020-08-14
  • 2019-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-12
相关资源
最近更新 更多