python 图像识别pytesseract快速设置

一、安装Tesseract

以window安装为例,参考:https://segmentfault.com/a/1190000014086067

note:

使用虚拟环境需要:

python 环境(或虚拟环境) \Lib\site-packages\pytesseract 目录下找到 pytesseract.py

打开 pytesseract.py , 在 32行 ,找到 变量 tesseract_cmd,修改 tesseract_cmd 值:

tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'

参考:https://www.pythonheidong.com/blog/article/753756/41839878d41e6db7e422/

二、python code

a.安装依赖

pip install pytesseract 
pip install pillow

b.sample code

simple.pnd为测试图片,注意是否当前的路径。

import pytesseract
from PIL import Image

image = Image.open("simple.png")
code = pytesseract.image_to_string(image)
print(code)

参考:https://segmentfault.com/a/1190000014091417

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值