【问题标题】:Why is pytesseract not identifying this image?为什么 pytesseract 无法识别此图像?
【发布时间】:2021-01-08 05:55:07
【问题描述】:

我正在尝试使用 tesseract 识别 python 中的单个数字。

我的代码是这样的:

import numpy as np
from PIL import Image
from PIL import ImageOps
import pytesseract
import cv2

def predict(imageArray):
    pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
    newImageArray = Image.open(imageArray)
    number = pytesseract.image_to_string(newImageArray, lang='eng', config='--psm 10 --oem 1 -c tessedit_char_whitelist=0123456789')

    return number

说这是8没有问题

但它不会将此识别为4

我的图片只是数字0-9

这只是一个这样的例子,在其他情况下它很难识别“明显/清晰”的数字。

目前我对起始图像image 所做的唯一事情就是转换颜色。使用以下内容:

cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

有什么方法可以提高准确性。我所有的图像都是清晰的计算机打印图像,所以我觉得准确度应该比它高很多。

【问题讨论】:

    标签: ocr tesseract python-tesseract


    【解决方案1】:

    您没有提供有关您使用的 tesseract 版本和语言模型的任何信息。 最佳模型无需任何预处理即可识别图像中的“4”。

    【讨论】:

    • 哪个型号最好?我正在将 python 与 pytesseract 和 tesseract-ocr-w64-setup-v5.0.0-alpha.20200223 一起使用。
    • 阅读 tesseract 文档:tesseract-ocr.github.io/tessdoc 我们不会代替您这样做。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 1970-01-01
    • 2019-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多