| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1784 人关注过本帖, 1 人收藏
标题:[原创]采用3线法和像素判别法来识别验证码
取消只看楼主 加入收藏
我是菜鸟哦
Rank: 6Rank: 6
等 级:贵宾
威 望:22
帖 子:921
专家分:209
注 册:2007-5-4
结帖率:73.33%
收藏(1)
 问题点数:0 回复次数:3 
[原创]采用3线法和像素判别法来识别验证码
采用3线法和像素判别法来识别数字
验证码地址http://passport.

所谓3线法(不知道以前有没有这样做,这个是我偶然想到的)就是竖线1条,横线两条,判断于图像的交点,用交点个数来做数字的代号,代号如有相同,则采用像素判别(比较大小)来区分

当然该方法有很大潜力改进,我今天无意间想到,就写出来供大家研究

Private check(1 To 3) As Integer
Private num(0 To 5) As Integer

Private Sub Command1_Click()
Dim i As Integer
Dim x, y, a, b, m, n As Integer
Dim blue As Integer
Dim clr, p As Long
Dim dis1, dis2, temp, clm As Integer


For i = 0 To 5
    Select Case i ‘6个数字分别分段识别
    Case 0
    dis1 = 0
    dis2 = 230
    clm = 150
    Case Else
    temp = dis2
    dis2 = dis2 + 180
    dis1 = temp
    clm = clm + 180
    End Select
   
   
   
    a = 0

For y = 0 To 450                   ’画竖线得交点
       clr = Picture1.Point(clm, y)
       blue = (clr \ &H10000) Mod &H100
      
       If blue < 254 Then
          If b = 0 Then
             a = a + 1
             b = 1
          End If
       Else
          b = 0
       End If
Next y
   
    check(1) = a
     a = 0
 
 
For x = dis1 To dis2                   ‘范围画2横向线,得交点

       clr = Picture1.Point(x, 170)
       blue = (clr \ &H10000) Mod &H100
      
       If blue < 254 Then
          If b = 0 Then
             a = a + 1
             b = 1
          End If
       Else
          b = 0
       End If
Next x

    check(2) = a
     a = 0
For x = dis1 To dis2
       clr = Picture1.Point(x, 240)
       blue = (clr \ &H10000) Mod &H100
      
       If blue < 254 Then
          If b = 0 Then
             a = a + 1
             b = 1
          End If
       Else
          b = 0
       End If
Next x
      
      check(3) = a
      
      
 If check(1) = 4 And check(2) = 2 And check(3) = 2 Then  ’用check做交点编码,找相应的数字,如果编码相同则判断蓝色像素的多少来区分
             p = 0
            
   For m = dis1 To dis2 Step 4
     For n = 0 To 450 Step 4
         clr = Picture1.Point(m, n)
         blue = (clr \ &H10000) Mod &H100
         If blue < 254 Then p = p + 1
     Next n
   Next m
  
   If p < 1300 Then
      num(i) = 0
   Else
      num(i) = 8
   End If
 End If
 
 If check(1) = 4 And check(2) = 1 And check(3) = 1 Then
              p = 0
            
   For m = dis1 To dis2 Step 4
     For n = 0 To 450 Step 4
         clr = Picture1.Point(m, n)
         blue = (clr \ &H10000) Mod &H100
         If blue < 254 Then p = p + 1
     Next n
   Next m
   
   If p < 1010 Then
      num(i) = 2
   Else
      num(i) = 3
   End If
End If


   If check(1) = 3 And check(2) = 1 And check(3) = 1 Then
              p = 0
            
   For m = dis1 To dis2 Step 4
     For n = 0 To 450 Step 4
         clr = Picture1.Point(m, n)
         blue = (clr \ &H10000) Mod &H100
         If blue < 254 Then p = p + 1
     Next n
   Next m
   
   If p < 950 Then
      num(i) = 7
   Else
      num(i) = 4
   End If
End If

 If check(1) = 2 And check(2) = 1 And check(3) = 1 Then num(i) = 1
 If check(1) = 5 And check(2) = 1 And check(3) = 1 Then num(i) = 5
 If check(1) = 5 And check(2) = 1 And check(3) = 2 Then num(i) = 6
 If check(1) = 4 And check(2) = 2 And check(3) = 1 Then num(i) = 9
 
Next i

MsgBox num(0) & num(1) & num(2) & num(3) & num(4) & num(5)

End Sub


Private Sub Timer1_Timer()  ‘更新图片
Picture1.Picture = LoadPicture(".\验证图片\验证码" & Text1.Text & ".gif ")
End Sub

[[it] 本帖最后由 我是菜鸟哦 于 2008-10-13 20:41 编辑 [/it]]

验证码识别.rar (22.79 KB)


未命名.jpg (10.65 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 申精 像素 判别 验证 
2008-10-13 19:44
我是菜鸟哦
Rank: 6Rank: 6
等 级:贵宾
威 望:22
帖 子:921
专家分:209
注 册:2007-5-4
收藏
得分:0 
这种贴都看完不给顶,又不是我抄袭的

偶是菜鸟鸟偶惧WHO?!!!!
2008-10-15 22:37
我是菜鸟哦
Rank: 6Rank: 6
等 级:贵宾
威 望:22
帖 子:921
专家分:209
注 册:2007-5-4
收藏
得分:0 
具体情况具体分析呗

偶是菜鸟鸟偶惧WHO?!!!!
2008-10-16 19:54
我是菜鸟哦
Rank: 6Rank: 6
等 级:贵宾
威 望:22
帖 子:921
专家分:209
注 册:2007-5-4
收藏
得分:0 
谢谢指教,学习ING

偶是菜鸟鸟偶惧WHO?!!!!
2008-10-17 20:22
快速回复:[原创]采用3线法和像素判别法来识别验证码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019879 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved