pytesseract image_to_string 不拉字符串,但没有错误

Jef*_*eff 1 image image-processing python-imaging-library python-3.x python-tesseract

我在 pytesseract 包中使用 image_to_string 函数将单个图片文件的多个部分转换为字符串。除此图像外,所有部件均正常工作:

在此处输入图片说明

这是我用来转换它的脚本:

from PIL import Image
import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-OCR/tesseract'

im = Image.open('image.png')
text = pytesseract.image_to_string(im)
print(text)
Run Code Online (Sandbox Code Playgroud)

这给出了输出:

—\—\—\N—\—\—\—\—\N

我尝试将图像分解成更小的部分,并将图像处理为 jpg 和 png。我该怎么做才能让它输出图像中的值?

tim*_*orn 6

使用不同的页面分段而不是默认的分段似乎有效。

text = pytesseract.image_to_string(im,config ='--psm 6'))
Run Code Online (Sandbox Code Playgroud)

根据 tesseract wiki,选项 6 假设一个统一的文本块。我尝试了其他选择,但只有这个有效。要检查其他页面分割方法,请阅读有关如何提高图像质量的 tesseract wiki。