python 识别图片中的文字信息方法

yipeiwu_com5年前Python基础

最近朋友需要一个可以识别图片中的文字的程序,以前做过java验证码识别的程序;

刚好最近在做一个python项目,所以顺便用Python练练手

1.需要的环境:

2.7或者3.4版本的python

2.需要安装pytesseract库

依赖PIL和tesseract-ocr库

本地环境是ubuntu,下面说一下 具体步骤:

2.7

1.安装PIL:

直接使用pip 安装; pip install Pillow

2.安装tesseract-ocr:

apt-get install tesseract-ocr

3.安装pytesseract

pip install pytesseract

使用python 3.4安装时;将pip 命令修改为pip3(都知道)

测试:

import pytesseract
from PIL import Image
img = Image.open('hb1.png')
data = pytesseract.image_to_string(img)
print (data)

注意: 会出现乱码

以上这篇python 识别图片中的文字信息方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python 自动补全(vim)

Python 自动补全(vim)

一、vim python自动补全插件:pydiction 可以实现下面python代码的自动补全: 1.简单python关键词补全 2.python 函数补全带括号 3.pytho...

python运行时强制刷新缓冲区的方法

需求:打印一颗”*”休息1s 代码如下: #!/usr/bin/python #coding=utf-8 ''' 暂停1s输出 ''' import time def print...

Python计算时间间隔(精确到微妙)的代码实例

Python计算时间间隔(精确到微妙)的代码实例

使用python中的datetime import datetime oldtime=datetime.datetime.now() print oldtime; x=1 while...

Python图像处理之识别图像中的文字(实例讲解)

Python图像处理之识别图像中的文字(实例讲解)

①安装PIL:pip install Pillow(之前的博客中有写过) ②安装pytesser3:pip install pytesser3 ③安装pytesseract:pip in...

ansible作为python模块库使用的方法实例

前言 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量...