Python使用tesserocr识别文字过程中遇到的一个问题

Python138

最近在使用Python识别PNG图像中包含的文字时遇到一个问题。解决过程记录如下。
(Python使用tesserocr的安装过程不再描述。)
在使用tesserocr识别PNG图像中的文字时,如果PNG比较"干净",背景没有噪音时,过程比较简单,代码如下:

from PIL import Image
import tesserocr

image = Image.open(r'../data/demo01.png')
print(tesserocr.image_to_text(image))

输出结果为:

This is some text, written in Arial, that will be read by
Tesseract. Here are some symbols: !@#$%"&'()

效果还算可以。

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长