)自動投票中驗證碼識別問題初探

來源:互聯網
上載者:User
自動投票中驗證碼識別問題初探 現在很多網站投票、發帖都採取了驗證碼機制,如果驗證碼位置角度是固定的話,就可以採取先採樣產生字模,然後進行對比,最後得到對應的驗證碼。這種方法基本上可以不用除噪,而且識別率達到百分之百準確。下面是我寫的驗證碼識別代碼: Static Words As Byte
Dim i As Integer
Dim m As Integer
Dim n As Integer
Dim FNum As Integer
Dim ImgStr As String
Dim Kuan As Integer
Dim Gao As Integer
Dim lColor As Long
Dim MaNub As Integer
Dim DImgStr As String
Dim ZuiHouMa As String
Dim YZMa As Integer
Dim TopKong As Integer
Dim LeftKong As Integer
Dim RightKong As Integer
Dim CYL(0 To 15) As Integer '差異率
'驗證圖片寬度55,高度16,從第六個點(編號5)開始,到第50個點(編號49)結束,共五個字,5*9=45 上空4下空2
'驗證圖片寬度100 高度25 從26點開始,每字寬9,右空2,上空5,高13
MaNub = 5   '一幅圖裡有幾個碼
Kuan = 9
Gao = 13
TopKong = 5
LeftKong = 26
RightKong = 2
WordX = (Me.Left + Picture1.Left) / Screen.TwipsPerPixelX + LeftKong
WordY = (Me.Top + Picture1.Top) / Screen.TwipsPerPixelY + TopKong
'MsgBox WordX & WordY

'ls = SetPixel(GetDC(0), WordX, WordY, vbGreen)
WordX = LeftKong
WordY = TopKong

ZuiHouMa = ""

For i = 0 To MaNub - 1
        
    ImgStr = ""
    
    For m = 0 To Gao - 1
        For n = 0 To Kuan - 1
            lColor = GetPixel(Picture1.hdc, WordX + n, WordY + m)
            If GetRedValue(lColor) > 100 And GetGreenValue(lColor) < 100 And GetBlueValue(lColor) < 100 Then
                ImgStr = ImgStr & "1"
            Else
                ImgStr = ImgStr & "0"
            End If
        Next n
    Next m

    YZMa = 9
    CYL(YZMa) = 100
    For m = 0 To 9
        CYL(m) = 0
        For n = 0 To Kuan * Gao - 1
            If (Mid(FontDat(m), n + 1, 1) = "1") And (Mid(ImgStr, n + 1, 1) = "0") Then CYL(m) = CYL(m) + 1
            If (Mid(FontDat(m), n + 1, 1) = "0") And (Mid(ImgStr, n + 1, 1) = "1") Then CYL(m) = CYL(m) + 1
        Next n
        If CYL(m) < CYL(YZMa) Then YZMa = m
    Next m
    ZuiHouMa = ZuiHouMa & Trim(Hex(YZMa))
    WordX = WordX + Kuan + RightKong
            
Next i
Text1.Text = ZuiHouMa

程式運行介面如下:

註:介面借用了網上下載的一個程式。。但識別核心是我自己寫的。

DEMO程式如下:
http://my82163.51.net/readcode.rar

 

 

其它連結:

WebBrowser抓圖樣本——截取網頁上的驗證碼圖片

踏破鐵鞋無覓處:網頁下載圖片的代碼

自動更換IP的輔助投票工具

自動投票中驗證碼識別問題初探

關於自動投票工具軟體的實現

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.