C# AspriseOCR验证码识别

可识别一些简单验证码

//http://www.cnblogs.com/longbo/
//可识别字母数字和符号
[DllImport("AspriseOCR.dll", EntryPoint = "OCR")]
public static extern IntPtr OCR(string file, int type);

//识别条形码
[DllImport("AspriseOCR.dll", EntryPoint = "OCRBarCodes")]
static extern IntPtr OCRBarCodes(string file, int type);

//ocr识别AspriseOCR.dll DevIL.dll ILU.dll,识别率高
private void button24_Click(object sender, EventArgs e)
{
    if (pictureBox3.Image != null)
    {
        string path = Application.StartupPath + "/ocr.bmp";
        pictureBox3.Image.Save(path, ImageFormat.Bmp);

        try
        {
            textBox3.Text += Marshal.PtrToStringAnsi(OCR(path, -1)).Replace("", ""); //将返回string,并以"\r\n"结尾
            textBox3.Select(textBox3.Text.Length, 1);
            textBox3.ScrollToCaret();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}
posted @ 2011-07-29 20:22  事理  阅读(8048)  评论(0编辑  收藏  举报