这篇文章主要介绍了Python编程实现的图片识别功能,涉及Python PIL模块的安装与使用技巧,需要的朋友可以参考下
本文实例讲述了Python编程实现的图片识别功能。分享给大家供大家参考,具体如下:
1. 安装PIL,官方没有WIN64位,Pillow替代
pip install Pillow-2.7.0-cp27-none-win_amd64.whl
2. 安装Pytesser
下载pytesser_v0.0.1.zip,解压后复制进Python27\Lib\site-packges\pytesser路径下,无pytesser则新建
在Python27\Lib\site-packges\pytesser中新建一pytesser.pth文件,内容为pytesser
在pytesser内,修改三点
① pytesser.py修改成__init.py__
② 修改pytesser.py
import Image
改为
from PIL import Image
tesseract_exe_name = 'tesseract' 改为tesseract_exe_name = 'Python27\\Lib\\site-packges\\pytesser\\tesseract' 注意\转义
③ 安装Tesseract
下载后解压,找到tessdata文件夹,用其替换掉pytesser解压后的tessdata文件夹即可。
不过除了测试用验证码之外,其余的系统验证码的识别率很低。
附测试代码
from pytesser import * from PIL import Image, ImageEnhance im = Image.open('D:\Python27\Lib\site-packages\pytesser\phototest.tif') im2 = Image.open(r'D:\Python27\Lib\site-packages\pytesser\fnord.tif','r') im3 = Image.open(r'F:\PROJECT\python\code\Study_1\src\20170424\cp.jpg','r') #文件读写模式以防报错 #图片处理1::黑白处理 enhancer = ImageEnhance.Contrast(im3) image2 = enhancer.enhance(5) image2.show() print image_to_string(image2) #图片处理2: 降噪处理 imgry = im3.convert('L') #灰度处理 #灰度处理基础上二值化处理 threshold = 140 table = [] for i in range(256): if i < threshold: table.append(0) else: table.append(1) out = imgry.point(table, '1') out.show() text = image_to_string(out) if text.isspace() : print "FAILE" else: print text #print text
以上是Python实现图片识别功能的示例分享的详细内容。更多信息请关注PHP中文网其他相关文章!

Inpython,YouAppendElementStoAlistusingTheAppend()方法。1)useappend()forsingleelements:my_list.append(4).2)useextend()orextend()或= formultiplelements:my_list.extend.extend(emote_list)ormy_list = [4,5,6] .3)useInsert()forspefificpositions:my_list.insert(1,5).beaware

调试shebang问题的方法包括:1.检查shebang行确保是脚本首行且无前置空格;2.验证解释器路径是否正确;3.直接调用解释器运行脚本以隔离shebang问题;4.使用strace或truss跟踪系统调用;5.检查环境变量对shebang的影响。

pythonlistscanbemanipulationusesseveralmethodstoremovelements:1)theremove()MethodRemovestHefirStocCurrenceOfAstePecifiedValue.2)thepop()thepop()methodremovesandremovesandurturnturnsananelementatagivenIndex.3)

pythristssupportnumereperations:1)addingElementSwithAppend(),Extend(),andInsert()。2)emovingItemSusingRemove(),pop(),andclear(),and clear()。3)访问andmodifyingandmodifyingwithIndexingAndexingAndSlicing.4)

使用NumPy创建多维数组可以通过以下步骤实现:1)使用numpy.array()函数创建数组,例如np.array([[1,2,3],[4,5,6]])创建2D数组;2)使用np.zeros(),np.ones(),np.random.random()等函数创建特定值填充的数组;3)理解数组的shape和size属性,确保子数组长度一致,避免错误;4)使用np.reshape()函数改变数组形状;5)注意内存使用,确保代码清晰高效。

播放innumpyisamethodtoperformoperationsonArraySofDifferentsHapesbyAutapityallate AligningThem.itSimplifififiesCode,增强可读性,和Boostsperformance.Shere'shore'showitworks:1)较小的ArraySaraySaraysAraySaraySaraySaraySarePaddedDedWiteWithOnestOmatchDimentions.2)

forpythondataTastorage,choselistsforflexibilityWithMixedDatatypes,array.ArrayFormeMory-effficityHomogeneousnumericalData,andnumpyArraysForAdvancedNumericalComputing.listsareversareversareversareversArversatilebutlessEbutlesseftlesseftlesseftlessforefforefforefforefforefforefforefforefforefforlargenumerdataSets; arrayoffray.array.array.array.array.array.ersersamiddreddregro


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

Atom编辑器mac版下载
最流行的的开源编辑器

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。