python实战===用python识别图片中的中文

栏目: Python · 发布时间: 8年前

内容简介:python实战===用python识别图片中的中文

需要安装的模块

PIL

pytesseract

需要下载的工具:

http://download.csdn.net/download/bo_mask/10196285

下载解压后,安装到 默认 的路径下,安装完成后如下图1:

python实战===用 <a href='https://www.codercto.com/topics/20097.html'>python</a> 识别图片中的中文

并且复制解压文件的 chi_sim.traineddata 文件到安装路径 C:\Program Files (x86)\Tesseract-OCR\tessdata   下图2,图3:

python实战===用python识别图片中的中文

python实战===用python识别图片中的中文

好的,如果你上面所有安装完了,那么还有最后一步,更改配置文件,位置如下图4:

python实战===用python识别图片中的中文

打开后将原来的注释掉,新增:

# CHANGE THIS IF TESSERACT IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY

# tesseract_cmd = 'tesseract'

tesseract_cmd = u'C:/Program Files (x86)/Tesseract-OCR/tesseract.exe'        #此路径是你安装后的路径,对应的是图1的路径

保存!环境配置结束~

如下图,保存为111.png:

python实战===用python识别图片中的中文

#test.py

from PIL import Image
import pytesseract

text=pytesseract.image_to_string(Image.open('111.png'),lang='chi_sim')
print(text)

执行结果:

python实战===用python识别图片中的中文

(─.─|||   。。。 。。。。

总结:

  1. 用到的模块本身不具备识别汉字的功能,因此引入了第三方工具。
  2. 从执行效果来看,能力还有待提高。

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Blog Design Solutions

Blog Design Solutions

Richard Rutter、Andy Budd、Simon Collison、Chris J Davis、Michael Heilemann、Phil Sherry、David Powers、John Oxton / friendsofED / 2006-2-16 / USD 39.99

Blogging has moved rapidly from being a craze to become a core feature of the Internetfrom individuals sharing their thoughts with the world via online diaries, through fans talking about their favori......一起来看看 《Blog Design Solutions》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

SHA 加密
SHA 加密

SHA 加密工具