当前位置:编程学习 > C#/ASP.NET >>

实现验证码图像文字的识别(C#调用DLL)

请先下载http://asprise.com/product/ocr/index.php?lang=csharp 的SDK.里面提供了详细的OCR方法,如下:

 
将发现图像框picbVeryfyCode里的文字和文本框.txtVeryfyCode.Text是一致的.

 
数字识别率我碰到的几乎是100%

 
http://blog.csdn.net/crabo/

 
[DllImport("AspriseOCR.dll")]
static extern string craboOCR(string file, int type);

 
private void GetVeryfyCode()
{
   if(File.Exists(_imgPath))//ok now?
   {
    try
    {
        this.picbVeryfyCode.Image = System.Drawing.Bitmap.FromFile(_imgPath);
        _veryfyCode = craboOCR(_imgPath,-1);   //将返回string,并以" "结尾!!
        _veryfyCode = _veryfyCode.Substring(0,4);
        this.txtVeryfyCode.Text = _veryfyCode;
    }
    catch(Exception e)
    {
       this.lblResult.Text += e.Message;
    }
   }
}
    
补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,