资源简介

本资源是来自实践项目,是项目中的验证码识别学习程序。稍微加一些参数即可实现正常识别模式。 压缩包中附带源代码 + 验证码 + 在线获取的验证码 (附带一个Google的灰度处理算法) 包含算法:灰度处理算法、二差值算法、特提取算法、学习模式算法、 以及验证码识别的整体思路和完整的实现方法。包括机器学习和机器自识别。 本源代码使用GPL授权协议。(不适合已经有经验的图形图像处理人员,适合新手。)

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace CaptcheIO
{
    public class CaptcheIO
    {
        /// 
        /// 全部特征码
        /// 

        public CaptcheData[] captcheArray;
        /// 
        /// 文件名称
        /// 

        private string file = “lib.txt“;

        /// 
        /// 构造函数
        /// 

        public CaptcheIO()
        {
            ReadCharacterLib(); //读取特征码库
        }

        /// 
        /// 添加一条特征
        /// 

        /// 特征码数据结构
        public void Add(CaptcheData captche)
        {
            string line_1 = ““;
            string line_2 = ““;
            line_1 = string.Format(“{0}={1}={2}={3}“captche.Codecaptche.Bearingcaptche.Linecaptche.Character);

            if (captcheArray.Length == 0)
            {
                File.AppendAllText(file line_1 + “\n“);
                ReadCharacterLib();
                return;
            }
            else
            {
                for (int i = 0; i < captcheArray.Length; i++)
                {
                    line_2 = string.Format(“{0}={1}={2}={3}“
                        captcheArray[i].Code
                        captcheArray[i].Bearing
                        captcheArray[i].Line
                        captcheArray[i].Character);
                    if (line_1 == line_2) return;
                }
            }
            File.AppendAllText(file line_1 + “\n“);
            ReadCharacterLib();
        }

        /// 
        /// 识别验证码
        /// 

        /// 验证码结构
        /// 识别错误返回null正确返回字符
        public string Is_Equal(CaptcheData captche)
        {
            string s = ““;
            for (int i = 0; i < captcheArray.Length; i++)
            {
                if (captcheArray[i].Bearing == captche.Bearing &&
                    captcheArray[i].Line == captche.Line &&
                    captcheArray[i].Character == captche.Character)
                {
                   s+=captcheArray[i].Code;
                }
            }
            return s;
        }

        /// 
        /// 保存特征库文件
        /// 

        public void Save()
        {
            string line = ““;
            for (int i = 0; i < captcheArray.Length; i++)
            {
                line += captcheArray[i].Code + “=“;
                line += captcheArray[i].Bearing + “=“;
                line += captcheArray[i].Line + “=“;
                line += captcheArray[i].Character + “\n“;
            }
            File.WriteAllText(file line Encoding.UTF8);
        }

        /// 
        /// 读取特征码库
        /// 

        private void ReadCharacterLib()
        {
            string[] lines = File.ReadAllLines(file Encodin

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2137  2011-04-30 14:13  Captche\yanmoCaptche\obj\Debug\Captche.csproj.FileListAbsolute.txt

     文件       1025  2011-04-29 19:01  Captche\CaptcheIO\obj\Debug\CaptcheIO.csproj.FileListAbsolute.txt

     文件       3514  2011-04-30 15:46  研磨网-验证码识别\obj\Debug\GoogleCaptche.csproj.FileListAbsolute.txt

     文件        955  2011-04-29 19:01  Captche\Http\obj\Debug\Http.csproj.FileListAbsolute.txt

     文件       3787  2011-04-30 15:10  Captche\Bin\lib.txt

     文件       2767  2011-04-30 17:17  Captche\SmartLib\obj\Debug\SmartLib.csproj.FileListAbsolute.txt

     文件      63236  2011-04-30 12:37  Captche\Bin\双垂直线特征.txt

     文件      11264  2011-04-28 22:24  研磨网-验证码识别\bin\Debug\GoogleCaptche.exe

     文件      11264  2011-04-28 22:24  研磨网-验证码识别\obj\Debug\GoogleCaptche.exe

    .......     14328  2011-04-30 15:46  研磨网-验证码识别\bin\Debug\GoogleCaptche.vshost.exe

     文件      94720  2011-04-30 14:59  Captche\Bin\SmartLib.exe

     文件      94720  2011-04-30 14:59  Captche\SmartLib\obj\Debug\SmartLib.exe

    .......     14328  2011-04-30 17:17  Captche\Bin\SmartLib.vshost.exe

     文件       3584  2011-04-29 09:16  Captche\yanmoCaptche\obj\Debug\Refactor\Captche.dll

     文件       6144  2011-04-30 14:14  Captche\Bin\Captche.dll

     文件       6144  2011-04-30 14:14  Captche\yanmoCaptche\obj\Debug\Captche.dll

     文件       5632  2011-04-29 19:23  Captche\Bin\CaptcheIO.dll

     文件       5632  2011-04-29 19:23  Captche\CaptcheIO\obj\Debug\CaptcheIO.dll

     文件       4608  2011-04-29 19:23  Captche\Bin\Http.dll

     文件       4608  2011-04-29 19:23  Captche\Http\obj\Debug\Http.dll

     文件       5632  2011-04-28 22:15  Captche\yanmoCaptche\obj\Debug\yanmoCaptche.dll

     文件       5632  2011-04-28 22:15  研磨网-验证码识别\bin\Debug\yanmoCaptche.dll

     文件       2158  2011-04-28 14:10  研磨网-验证码识别\bin\Debug\0.bmp

     文件       2048  2011-04-30 13:55  Captche\Bin\source\1.bmp

     文件       2158  2011-04-28 14:44  研磨网-验证码识别\bin\Debug\1.bmp

     文件       2158  2011-04-29 08:00  研磨网-验证码识别\bin\Debug\10.bmp

     文件       2048  2011-04-30 15:08  Captche\Bin\source\1000.bmp

     文件       2048  2011-04-30 13:15  Captche\Bin\source\1001.bmp

     文件       2048  2011-04-30 12:59  Captche\Bin\source\1005.bmp

     文件       2048  2011-04-30 13:45  Captche\Bin\source\1008.bmp

............此处省略2685个文件信息

评论

共有 条评论