Mac安装使用tesseract-ocr

0.介绍
Tesseract是一个开源的OCR引擎,能识别100多种语言(中,英,韩,日,德,法…等等),但是Tesseract对手写的识别能力较差。

1.安装

//先安装依赖库libpng, jpeg, libtiff, leptonica
brew install leptonica
//安装tesseract
brew install  tesseract
//与python对接需要安装的包
pip3 install Pillow
pip3 install pytesseract

2.下载语言库
下载地址:https://github.com/tesseract-ocr/tessdata

根据自己的需求选择所要的语言库,在这里我们选择的是简体中文所以选择的库是:chi_sim.traineddata、eng.traineddata
在这里插入图片描述
将文件拷贝到到:/usr/local/Cellar/tesseract/3.04.01_2/share/tessdata目录下。
3.Tesseract使用
终端输入命令:tesseract --help

4.案例

#coding:utf-8

from PIL import Image
import pytesseract
im = Image.open('3.png')
result = pytesseract.image_to_string(im)
print(result)

多种语言同时识别

# coding:utf-8

from PIL import Image
import pytesseract

# 图片最好是白底黑字
im = Image.open('13.png')

result = pytesseract.image_to_string(im, lang='chi_sim+eng')
print(result)

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值