


Example sharing of Python implementing image recognition function
这篇文章主要介绍了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
The above is the detailed content of Example sharing of Python implementing image recognition function. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to download DeepSeek Xiaomi? Search for "DeepSeek" in the Xiaomi App Store. If it is not found, continue to step 2. Identify your needs (search files, data analysis), and find the corresponding tools (such as file managers, data analysis software) that include DeepSeek functions.

The key to using DeepSeek effectively is to ask questions clearly: express the questions directly and specifically. Provide specific details and background information. For complex inquiries, multiple angles and refute opinions are included. Focus on specific aspects, such as performance bottlenecks in code. Keep a critical thinking about the answers you get and make judgments based on your expertise.

Just use the search function that comes with DeepSeek. Its powerful semantic analysis algorithm can accurately understand the search intention and provide relevant information. However, for searches that are unpopular, latest information or problems that need to be considered, it is necessary to adjust keywords or use more specific descriptions, combine them with other real-time information sources, and understand that DeepSeek is just a tool that requires active, clear and refined search strategies.

DeepSeek is not a programming language, but a deep search concept. Implementing DeepSeek requires selection based on existing languages. For different application scenarios, it is necessary to choose the appropriate language and algorithms, and combine machine learning technology. Code quality, maintainability, and testing are crucial. Only by choosing the right programming language, algorithms and tools according to your needs and writing high-quality code can DeepSeek be successfully implemented.

Detailed explanation of DeepSeekAPI access and call: Quick Start Guide This article will guide you in detail how to access and call DeepSeekAPI, helping you easily use powerful AI models. Step 1: Get the API key to access the DeepSeek official website and click on the "Open Platform" in the upper right corner. You will get a certain number of free tokens (used to measure API usage). In the menu on the left, click "APIKeys" and then click "Create APIkey". Name your APIkey (for example, "test") and copy the generated key right away. Be sure to save this key properly, as it will only be displayed once

Binance Dual Currency Financial Management: In-depth analysis and operation guide This article will in-depth discussion on the operating mechanism, risks and benefits of Binance Dual Investment, and provide detailed operation steps. Dual currency wealth management is a high-risk, high-yield investment strategy, similar to the option seller's strategy, and novices need to operate with caution. What is Binance Dual Currency Financial Management? Binance Dual Currency Financial Management is a financial management product provided by Binance Exchange, allowing users to buy and sell cryptocurrencies at preset prices on specific dates in the future to earn fixed income, but they have to bear the risk of price fluctuations. "Dual Currency" refers to transactions involving cryptocurrencies and stablecoins. Currently, Binance supports a variety of cryptocurrencies to participate in dual-currency financial management. Although it can obtain fixed income, it is not a guaranteed investment, and there is a possibility of losses or even huge losses.

PiNetwork is about to launch PiBank, a revolutionary mobile banking platform! PiNetwork today released a major update on Elmahrosa (Face) PIMISRBank, referred to as PiBank, which perfectly integrates traditional banking services with PiNetwork cryptocurrency functions to realize the atomic exchange of fiat currencies and cryptocurrencies (supports the swap between fiat currencies such as the US dollar, euro, and Indonesian rupiah with cryptocurrencies such as PiCoin, USDT, and USDC). What is the charm of PiBank? Let's find out! PiBank's main functions: One-stop management of bank accounts and cryptocurrency assets. Support real-time transactions and adopt biospecies

This article explores the quantitative trading functions of the three major exchanges, Binance, OKX and Gate.io, aiming to help quantitative traders choose the right platform. The article first introduces the concepts, advantages and challenges of quantitative trading, and explains the functions that excellent quantitative trading software should have, such as API support, data sources, backtesting tools and risk control functions. Subsequently, the quantitative trading functions of the three exchanges were compared and analyzed in detail, pointing out their advantages and disadvantages respectively, and finally giving platform selection suggestions for quantitative traders of different levels of experience, and emphasizing the importance of risk assessment and strategic backtesting. Whether you are a novice or an experienced quantitative trader, this article will provide you with valuable reference
