private void button1_Click(object sender, EventArgs e)
{
WebRequest request = WebRequest.Create("https://bj.ac.10086.cn/ac/ValidateNum?smartID=1247945447 ");
WebResponse response = request.GetResponse();
Stream st = response.GetResponseStream();
Bitmap bitmap = (Bitmap)Bitmap.FromStream(st);
UnCodebase ud = new UnCodebase(bitmap);
//bitmap = ud.GrayByPixels();
//ud.ClearNoise(128,2);
pictureBox1.Image = bitmap;
tessnet2.Tesseract
ocr = new tessnet2.Tesseract();//声明一个OCR类
ocr.SetVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
//设置识别变量,当前只能识别数字。
ocr.Init(@" D:\tessdata", "eng", false);
//应用当前语言包。注,Tessnet2是支持多国语的。语言包下载链接:http://code.google.com/p/tesseract-ocr/downloads/list
List<tessnet2.Word> result = ocr.DoOCR(bitmap, Rectangle.Empty);//执行识别操作
string code = result[0].Text;
textBox1.Text= code;
}
}
c#识别图片验证码
最新推荐文章于 2024-07-09 21:43:35 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)