操作系统:ubuntu 16.04
python3版本:3.5.2
1、预装python模块te
1) sudo pip3 install pillow
安装PIL模块,在python2中有这个模块,在python3中需要安装pillow模块,这个模块包含了PIL模块
2) sudo pip3 install pytesseract
2、下载tersseract-ocr,在github的wiki有这个命令,地址:https://github.com/tesseract-ocr/tesseract/wiki
执行完这两个命令,它这里给的命令有点问题,应该是
sudo apt-get install tesseract-ocr
sudo apt-get install libtesseract-dev
下载完成
3、
创建一个python脚本,名为 pic_tostring.py
代码如下
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
from PIL import Image
import pytesseract
text=pytesseract.image_to_string(Image.open('w.JPG'),lang='eng')
print(text)
4、准备一个带有字母的图片
5、运行
python3 pic_tostring.py
6、结果
结果可能不是很准确
参考:
https://blog.csdn.net/qiushi_1990/article/details/78041375