程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> 圖像識別方面CSDN驗證碼的識別

圖像識別方面CSDN驗證碼的識別

編輯:.NET實例教程


簡單驗證碼的識別:CSDN驗證碼的識別
取圖像部分,ASP.Net_SessionID=這個值你要自己取這樣的話就可以做成自動登錄了

private Stream geturl(ref string str)
        {
            string url = "http://www.csdn.Net/member/ShowExPwd.ASPx";
            WebRequest myWebRequest = WebRequest.Create(url);
        
            myWebRequest.Headers.Add("CookIE","ASP.Net_SessionId=tr0p4g45xa0qzg45bmlqprnn");
            WebResponse myWebResponse = myWebRequest.GetResponse();
            Stream ReceiveStream = myWebResponse.GetResponseStream();    
            str=myWebResponse.Headers[6];
            return ReceiveStream;
            
        }
        private string getNumber()
        {
            string str;
            str="";
            Stream geturlStream =geturl(ref str);
            Bitmap map = new Bitmap(geturlStream,false);
            pictureBox1.Image = (Image)map;
            csdn csdn1= new csdn ();
            return csdn1.readMap(map)+str;
        }

驗證碼識別部分(很簡單類型的): 
分割圖片變成四個部分.
接下來判斷象素點.再判斷特征點 100%識別

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace binbin
{
    /**//// <summary>
    /// Class1 的摘要說明。
    /// </summary>
    public class csdn
    {
        public csdn()
        {
            
        }
        public string readMap(Bitmap image)
        {
            string str;
            RectangleF[] block=new RectangleF[4];  block[0]=new Rectangle(3,0,8,18);
            block[1]=new Rectangle(12,0,8,18);
            block[2]=new Rectangle(21,0,8,18);
            block[3]=new Rectangle(30,0,8,18);
            //分別克隆圖片的四個部分    
            Bitmap[] s=new Bitmap[4];
            s[0]=image.Clone(block[0],PixelFormat.DontCare);
            s[1]=image.Clone(block[1],PixelFormat.DontCare);
            s[2]=image.Clone(block[2],PixelFormat.DontCare);
            s[3]=image.Clone(block[3],PixelFormat.DontCare);
            str=ReadMap(s[0]).ToString();
            str=str+ReadMap(s[1]).ToString();
            str=str+ReadMap(s[2]).ToString();
            str=str+ReadMap(s[3]).ToString();
            return str;
        }
        private int ReadMap(Bitmap k)
        {
            int n=0;
            int m=0;
            Color color;
            for(int i=7; i>=0;i--)
            {
                for( int j=17; j>=0;j--)
                {
                    color=k.GetPixel(i,j);
                    if (color.GetBrightness()==1.0)
                    {
                        n=n+1;//白色點
       &nb
sp;            }
                    else
                    {
                        m=m+1;//藍色點
                    }

                }
            }
            switch(m)
            {
                case 22:
                    color=k.GetPixel(7,12);
                    if (color.GetBrightness()==1)
                    {
                        return 2;
                    }
                    else
                    {
                        return 3;
                    }
                case 25:
                    return 4;
                case 26:
                    return 5;
                case 28:
                    return 0;
case 30:
                    return 8;
                case 18: //18 29還要特殊處理
                    color=k.GetPixel(7,4);
                    if (color.GetBrightness()==1)
                        {
                            return 1;
                        }
                    else
                        {
                            return 7;
                        }
                case 29:

                    color=k.GetPixel(1,15);
                    if (color.GetBrightness()==1)
                    {
                        return 6;
                    }
                    else
                    {
                        return 9;
                    }
                default:
                    break;
            }
            return -1;
        }
    }
}
http://blog.csdn.Net/gisfarmer/archive/2009/02/04/3861736.ASPx


               


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved