Tesserorc在python运用中入的坑

2018-05-29  本文已影响0人  机器视觉CV_有三言选

这个例程是基于《python3网络爬虫开发实践》一书


以下是测试程序

import tesserocr

from PILimport Image

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

#print(image)

print(tesserocr.image_to_text(image))


1.安装Tersseract

相关链接:

tesserocr GitHub:https//github.com/sirfz/tesserocr

tesserocr PyPI:https://pypi.python.org/pypi/tesserocr

tesseract下载地址:http : //digi.bib.uni-mannheim.de/tesseract

tesseract GitHub:https//github.com/tesseract-ocr/tesseract

tesseract语言包:https//github.com/tesseract-ocr/tessdata

tesseract文档:https//github.com/tesseract-ocr/tesseract/wiki/Documentation

next到底就行了

2.安装tesserocr和pillow模块

2.1tesserocr

我安装时出现了以下错误

后来通过whl来安装才最终成功的

whl安装包下载链接

Releases · simonflueckiger/tesserocr-windows_build · GitHub

把下载下来的安装包放在python安装路径里

选择合适的版本下载   运行pip3 install tesserocr-2.2.2-cp36-cp36m-win_amd64.whl

加粗斜体的是下载下来的文件名。

2.2安装pillow

没什么问题 直接运行  pip3 install pillow就行了 若还是有问题,应该也可以用whl进行安装

3在pycharm运行出现报错的原因

出现以下报错

Failed to init API, possibly an invalid tessdata path: C:\\

解决办法是将C:\Program Files (x86)\Tesseract-OCR  的tessdata文件夹copy到python的安装路径中

上一篇下一篇

猜你喜欢

热点阅读