Tesseract 使用

Tesseract 使用

tesseract 是一套流行的OCT算法。专门做图片内容识别。我们只需要下载相应的训练数据就能使用tesseract进行图片内容读取。

安装参考:https://jingyan.baidu.com/article/219f4bf788addfde442d38fe.html

在python中使用

安装pytesseract: pip install pytesseract

import pytesseract
from PIL import Image

image = Image.open('QQ.png')

result = pytesseract.image_to_string(image, lang='chi_sim')
print(result)

对图片进行处理:

from PIL import Image

import pytesseract

image = Image.open('./douban.jpg')

# 灰度化
image = image.convert('L')
# 杂点清除掉。只保留黑的和白的。返回像素对象
data = image.load()
w, h = image.size #ndarry pandas
for i in range(w):
    for j in range(h):
        if data[i, j] > 120:
            data[i, j] = 255 # 纯白
        else:
            data[i, j] = 0 # 纯黑
image.save('clean_captcha.png')
image.show()

result = pytesseract.image_to_string(image, lang='eng')
print(result)


image.show()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值