c#发布一个赶集网的图片电话号码识别的代码

以前帮朋友写的代码,现在公布出来,道理很简单的,切割,提取验证码,因为验证码字体并未重合,所以切割起来相当的简单,如果您要做分类信息的网站,采集还是可取的,识别率100%

疯狂代码原创发布,转载请注明出处

C#代码如下:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace CrazyCoder.Common.Decode
{
    public class GanjiImageDecode : CrazyCoder.Common.Decode.ImageDeCodeBase
    {
        public GanjiImageDecode(Bitmap pic) : base(pic) { }
        public GanjiImageDecode(string path) : base(path) { }
      
        //特征码数组
        string[] CodeArray = new string[] {
"0001111100000111111100011100011100110000011011000000011110000000111100000001111000000011110
0000001101100000110011100011100011111110000011111000",//0
"0111111110110011001100110011001100110011001100110011",//1
"00111110001111111011000011100000001100000001100000011000000111000011100000111000001100000011
0000000111111111111111111",//2
"00111110001111111011000011100000001100000001100000011100001111000001111000000011100000001111
0000111011111110001111100",//3
"00000011100000000111000000011110000001101100000110011000011000110001100001100111000011001111
111111111111111111000000011000000000110000000001100",//4
"11111111011111111011000000011000000011000000011111100000000111000000011100000001100000001101
0000111111111110011111100",//5
"00011110000011111110011100010001100000001100000000110011110011111111101110000111110000001101
10000011011100011100111111100001111100",//6
"11111111111111110000011000001100000011000001100000110000001100000010000001100000011000000110
000001100000",//7
"00111110001111111011100011111000001111100011101111111001111111011100011111000001111000001111
1000111011111110001111100",//8
"00111110000111111100111000111011000001101100000111111000111101111110110011110011000000001100
00000110001000111001111111000011111000",//9
"11111111"//-
        };
        public Bitmap[] GetPic()
        {
            ToGrayByPixels(); //灰度处理
            Bitmap bmp = GetPicValidByValue(128);
            Bitmap[] pics = GetSplitPics2(bmp,128);   //分割
            for (int i = 0; i < pics.Length; i++)
            {
                if (pics[i] != null)
                {
                    Bitmap b = pics[i];
                    pics[i] = GetPicValidByValue(pics[i], 128);
                    b.Dispose();
                }
            }
            return pics;
        }
        public string GetCodeString()
        {
            Bitmap[] pics = GetPic();
            string numStr = "";
            for (int i = 0; i < pics.Length; i++)
            {
                string str = GanjiImageDecode.GetSingleBmpCode(pics[i], 128);
                for (int j = 0; j < CodeArray.Length; j++)
                {
                    if (CodeArray[j] == str)
                    {
                        if (j < CodeArray.Length - 1)
                        {
                            numStr += j.ToString();
                        }
                        else
                        {
                            numStr += "-";
                        }
                    }
                }
            }
            return numStr;
        }
    }
}


 
以前帮朋友写的代码,现在公布出来,道理很简单的,切割,提取验证码,因为验证码字体并未重合,所以切割起来相当的简单,如果您要做分类信息的网站,采集还是可取的,识别率100%
 

你可能感兴趣的:(String,C#,null,Class,Path,电话)