Python 的pytesscer 的识别功能初探

1.环境配置:

window 64 位
本来要安装PIL,但是PIL在window上没有64位的,转而安装 Pillow
其它的博客写了要安装Pip,我因为直接电脑上有,所以直接省略这个环节.
安装pytesser 安装地址
pytesser 这个库依赖 tesseract安装地址

Pillow的Github仓库

官方建议的Window的安装方法

We provide binaries for Windows in the form of Python Eggs and Python Wheels:

Python Eggs
pip does not support Python Eggs; use easy_install instead.
$ easy_install Pillow

Python Wheels
Experimental. Requires setuptools >=0.8 and pip >=1.4.1
$ pip install –use-wheel Pillow

If the above does not work, it’s likely because we haven’t uploaded a wheel for the latest >version of Pillow. In that case, try pinning it to a specific version:
$ pip install –use-wheel Pillow==2.6.1


1.安装pytesser这个库,这个免安装的,直接从安装地址 解压出来.
2.解压到 你的Python目录下的/Lib\site-packages 的里面 (这里你可以新建pytesser文件,把所有文件复制进去)
3.然后你需要在 \Lib\site-packages 这个目录下,新建一个 pytessera.pth 这个文件,然后文件中填入你刚才新建的文件的名字pytesser.

测试程序:

    from pytesser import *


def mian() :

    im = Image.open(r'C:\Users\Administrator\Desktop\fonts_test.png')
    text = image_to_string(im)
    print text

问题:

问题1: Image的问题找不到.因为我们装的不是PIL,所以在pytesser找不到Imaeg,你找到pytesser这个文件,然后在import改成 from pytesser import Image可以解决

问题2:
C:\Python27\python.exe D:/pycharm_project/android_install/imagel.py
Traceback (most recent call last):
File “D:/pycharm_project/android_install/imagel.py”, line 26, in
mian()
File “D:/pycharm_project/android_install/imagel.py”, line 10, in mian
text = image_to_string(im)
File “C:\Python27\lib\site-packages\pytesser\pytesser.py”, line 31, in image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File “C:\Python27\lib\site-packages\pytesser\pytesser.py”, line 21, in call_tesseract
proc = subprocess.Popen(args)
File “C:\Python27\lib\subprocess.py”, line 711, in init
errread, errwrite)
File “C:\Python27\lib\subprocess.py”, line 959, in _execute_child
startupinfo)
WindowsError: [Error 2]

Process finished with exit code 1

遇到上面这个问题,在你的py的最上面加入这行,
import os
os.chdir(r’*\site-packages\pytesser’)


识别中文:
在tesseract的命令行里面加 -l 参数, 中文是 -l chi_sim 中文简体,是这么写的参数
而且还要下载语言包,语言包地址
下载对应的语言包之后,在你的tesseract所在的文件里面有个tessdata的目录,
把对应的语言包下载放进去就可以了.不过目前的识别效果是两个字,呵呵

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值