Tesseract:大写字符的问题
Tesseract: problems with upper-case character
我在 Python 中使用 Tesseract。我有一张图片,里面有 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 的值不同,但没有适合我的问题
从 Tesseract 3 更新到 Tesseract 5 解决了这个问题
我在 Python 中使用 Tesseract。我有一张图片,里面有 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 的值不同,但没有适合我的问题
从 Tesseract 3 更新到 Tesseract 5 解决了这个问题