自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

C#聯(lián)通新版驗證碼識別的實現(xiàn)

開發(fā) 后端
以前寫了篇 聯(lián)通充值卡自動充值的實現(xiàn),最近發(fā)現(xiàn)聯(lián)通官網(wǎng)改版了,隨便看了下發(fā)現(xiàn)新版的驗證碼和以前的不同,發(fā)了點時間研究了下他的識別碼。

以前寫了篇 聯(lián)通充值卡自動充值的實現(xiàn),最近發(fā)現(xiàn)聯(lián)通官網(wǎng)改版了,隨便看了下發(fā)現(xiàn)新版的驗證碼和以前的不同,發(fā)了點時間研究了下他的識別碼,它現(xiàn)在的驗證碼如下:

現(xiàn)在將識別步驟說下

1,轉(zhuǎn)換灰度圖片

2,清除2px的邊框

3,分割驗證碼個數(shù) (4)

4,生成字模庫

經(jīng)過以上步驟,可以得到下面這個效果

下面為部分實現(xiàn)代碼

  1. public String GetCheckString(Bitmap bitmap) { 
  2.            UnCodebase ud = new UnCodebase(bitmap); 
  3.            ud.GrayByPixels(); 
  4.            ud.ClearPicBorder(2); 
  5.            ud.CutMap(14, 15, 0, 0); 
  6.            bitmap = ud.bmpobj; 
  7.          //  bitmap = ud.ClearNoise(128, 1); 
  8.            String chkcode = ""
  9.            Bitmap[] arrmap = ud.SplitImg(bitmap, 4, 1); 
  10.            foreach (Bitmap item in arrmap) { 
  11.                String str = ud.GetCodebybitmap(item, 128); 
  12.                Boolean isEques = false
  13.                foreach (String strss in code) { 
  14.                    String[] a = strss.Split(':'); 
  15.                    if (str == a[1]) { 
  16.                        chkcode += a[0]; 
  17.                        isEques = true
  18.                        break
  19.                    } 
  20.                } 
  21.                if (!isEques) { 
  22.                    String strCurrent = ""
  23.                    double max = 0.0; 
  24.                    foreach (String strss in code) { 
  25.                        int len1, len2, min, count = 0; 
  26.                        String[] a = strss.Split(':'); 
  27.                        len1 = a[1].Length; 
  28.                        len2 = str.Length; 
  29.                        min = len1; 
  30.                        if (min > len2) { 
  31.                            min = len2; 
  32.                        } 
  33.                        for (int i = 0; i < min; i++) { 
  34.                            if (str[i] == a[1][i]) { 
  35.                                count++; 
  36.                            } 
  37.                        } 
  38.                        double currrent = (count * 100.0 / min); 
  39.                        if (max < currrent) { 
  40.                            max = currrent; 
  41.                            strCurrent = a[0].Trim(); 
  42.                        } 
  43.                    } 
  44.                    chkcode += strCurrent.Trim(); 
  45.                } 
  46.            } 
  47.            return chkcode; 
  48.        } 

通過這些處理后,識別成功率在90+%以上,

下面附上測試地址,代碼  100%C#實現(xiàn),方便asp.net調(diào)用,如果是C/C++實現(xiàn) asp.net 調(diào)非托管的有些麻煩,非得放到System32 或是一個絕對路徑下麻煩

測試地址

http://www.fox163.com/UniconTest.aspx

本文轉(zhuǎn)自:http://www.cnblogs.com/ningqhai/p/3684318.html

責任編輯:林師授 來源: 博客園
相關推薦

2009-08-13 10:47:29

C#創(chuàng)建驗證碼

2009-08-06 16:30:58

C#代碼和驗證碼圖片

2009-08-12 11:05:00

2013-06-19 10:19:59

2021-07-22 10:25:07

JS驗證碼前端

2015-09-21 15:31:05

php實現(xiàn)驗證碼

2020-12-29 05:33:03

Serverless驗證碼架構

2022-05-11 07:41:31

Python驗證碼

2023-10-27 08:53:13

Python驗證碼圖片識別

2024-01-29 08:32:10

Python驗證碼識別

2009-12-16 15:46:41

Ruby on rai

2021-06-16 06:58:09

TensorFlow識別驗證碼

2020-09-29 06:43:12

Java

2009-06-26 15:17:27

jQuery

2009-11-23 16:59:23

PHP圖形驗證碼

2020-11-16 07:28:53

驗證碼

2009-08-11 14:05:28

JSP驗證碼

2009-02-09 14:17:36

2021-01-19 10:29:34

短信驗證碼密碼
點贊
收藏

51CTO技術棧公眾號