python驗證碼識別實例代碼
本文研究的主要是Python驗證碼識別的相關(guān)代碼,具體如下。
Talk is cheap, show you the Code!
import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans from PIL import Image #打開圖像 im=np.array(Image.open('yzm.png')) #得到圖像3個維度 h,w,san=im.shape X=[(h-x,y) for x in range(h) for y in range (w) if im[x][y][2]<200] #將X轉(zhuǎn)換成numpy的array類型,方便后續(xù)運算操作 X=np.array(X) n_clusters=4 k_means=KMeans(init='k-means++',n_clusters=n_clusters) k_means.fit(X) k_means_labels=k_means.labels_ k_means_cluster_centers=k_means.cluster_centers_ k_means_labels_unique=np.unique(k_means_labels) colors=['#4EACC5','#FF9C34','#4E9A06','#FF3300'] plt.figure() plt.hold(True) for k,col in zip(range(n_clusters),colors): my_members=k_means_labels==k cluster_center=k_means_cluster_centers[k] plt.plot(X[my_members,1],X[my_members,0],'w',markerfacecolor=col,marker='.') plt.plot(cluster_center[1],cluster_center[0],'o',markerfacecolor=col,markeredgecolor='k',markersize=6) plt.title('KMeans') plt.grid(True) plt.show()
總結(jié)
以上就是本文關(guān)于python驗證碼識別實例代碼的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!
相關(guān)文章
PyQt5 文本輸入框自動補全QLineEdit的實現(xiàn)示例
這篇文章主要介紹了PyQt5 文本輸入框自動補全QLineEdit的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05如何使用django-treebeard實現(xiàn)樹類型存儲與編輯
這篇文章主要介紹了使用django-treebeard實現(xiàn)樹類型存儲與編輯的宣相關(guān)操作代碼,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2024-08-08使用PyInstaller將python轉(zhuǎn)成可執(zhí)行文件exe筆記
這篇文章主要介紹了使用PyInstaller將python轉(zhuǎn)成可執(zhí)行文件exe筆記,需要的朋友可以參考下2018-05-05利用python3 的pygame模塊實現(xiàn)塔防游戲
這篇文章主要介紹了利用python3 的pygame模塊實現(xiàn)塔防游戲,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-12-12influx+grafana自定義python采集數(shù)據(jù)和一些坑的總結(jié)
一些數(shù)據(jù)的類型不正確會導(dǎo)致no datapoint的錯誤,真是令人抓狂,本文就是總結(jié)一下采集數(shù)據(jù)種的一些坑,希望大家可以從中獲益2018-09-09