And*_*ndy 5 ocr tesseract image-processing python-imaging-library
我在图像中有一个简单的文本image_ball.png。通常 Tesseract 的 OCR 效果很好,但是对于这个特定的图像,它总是返回一个空字符串。

In [1]: from PIL import Image
In [2]: from pytesseract import image_to_string
In [3]: img = Image.open("image_ball.png")
In [4]: image_to_string(img)
Out[5]: u''
Run Code Online (Sandbox Code Playgroud)
到目前为止,我找不到解决方法。我怎么能弄清楚这张图片出了什么问题?
版本是:
In [6]: import PIL
In [7]: PIL.__version__
Out[7]: '4.0.0'
$ tesseract -v
tesseract 4.0.0
leptonica-1.77.0
libgif 5.1.4 : libjpeg 9c : libpng 1.6.36 : libtiff 4.0.10 : zlib 1.2.11 : libwebp 1.0.2 : libopenjp2 2.3.0
Found AVX2
Found AVX
Found SSE
Run Code Online (Sandbox Code Playgroud)
编辑
我也尝试将图像转换为黑/白。但它仍然不被认可。
In [6]: image = img.convert('L')
In [7]: image_to_string(image)
Out[8]: u''
Run Code Online (Sandbox Code Playgroud)
编辑 2
放大图像可为您提供所需的输出。
image = cv2.imread("Ball.png", cv2.IMREAD_GRAYSCALE)
cv2.dilate(image, (5, 5), image)
print(pytesseract.image_to_string(image), config='--psm 7')
Run Code Online (Sandbox Code Playgroud)
球
| 归档时间: |
|
| 查看次数: |
3409 次 |
| 最近记录: |