Previously wrote a unicom recharge card automatic top-up implementation, recently found that Unicom official website revision, casually looked under the new version of the verification code and the previous difference, sent a little time to study the next his identification code, it is now the verification code as follows
Now identify the steps
1, convert grayscale image
2, clear the 2px border
3, the number of partition verification code (4)
4, create Font library
After the above steps, you can get the following effect
The following is a partial implementation of the Code
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
publicString GetCheckString(Bitmap bitmap) { UnCodebase ud = newUnCodebase(bitmap); ud.GrayByPixels(); ud.ClearPicBorder(2); ud.CutMap(14, 15, 0, 0); bitmap = ud.bmpobj; // bitmap = ud.ClearNoise(128, 1); String chkcode = ""; Bitmap[] arrmap = ud.SplitImg(bitmap, 4, 1); foreach(Bitmap item in arrmap) { String str = ud.GetCodebybitmap(item, 128); Boolean isEques = false; foreach(String strss incode) { String[] a = strss.Split(‘:‘); if(str == a[1]) { chkcode += a[0]; isEques = true; break; } } if(!isEques) { String strCurrent = ""; doublemax = 0.0; foreach(String strss incode) { intlen1, len2, min, count = 0; String[] a = strss.Split(‘:‘); len1 = a[1].Length; len2 = str.Length; min = len1; if(min > len2) { min = len2; } for(inti = 0; i < min; i++) { if(str[i] == a[1][i]) { count++; } } doublecurrrent = (count * 100.0 / min); if(max < currrent) { max = currrent; strCurrent = a[0].Trim(); } } chkcode += strCurrent.Trim(); } } returnchkcode; } |
After these treatments, the recognition success rate is above 90+%,
The following is attached to the test address, Code 100%c# implementation, easy to make an ASP. NET call, if it is C + + implementation of ASP.
Test address
Http://www.fox163.com/UniconTest.aspx
--Happy Sea
Blog Address: http://www.cnblogs.com/ningqhai/