請先下載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;
}
}
}