可识别一些简单验证码

//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);
        }
    }
}

相关文章:

猜你喜欢
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-08-15
相关资源
相似解决方案