Using Tessnet2_32.dll to realize OCR verification code recognition

Source: Internet
Author: User
Tags pack tesseract ocr
Using System;  
Using System.Collections.Generic;  
Using System.Web;  
Add using System.Net;  
Using System.IO; Using Tessnet2;  
Reference Tessnet2_32.dll using System.Drawing;  
Using Getcodes;  
  
Using System.Text;  
        Public partial class OCR:System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {  
        WebRequest request = WebRequest.Create ("http://sz.2zf.cn/js/code2.asp"); 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);  
  
        Save Display string Savepath = "~/photos/orc.gif"; Bitmap.  
        Save (Server.MapPath (Savepath), System.Drawing.Imaging.ImageFormat.Gif);  
  
        Image1.imageurl = Savepath; Tessnet2. Tesseract OCR = new Tessnet2. Tesseract ()//declares an OCR class OCR. SetvAriable ("Tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); Set the identification variable//OCR.  
        Init (NULL, "Eng", false); Ocr. Init (Server.MapPath ("~/language"), "Eng", true); Applies the current language pack. Note that Tessnet2 is supported in Mandarin. Language pack Download Link: http://code.google.com/p/tesseract-ocr/downloads/list list<tessnet2. word> result = OCR. DOOCR (bitmap, rectangle.empty);//Perform recognition operation string code = Result[0].  
        Text;  
    Label1.Text = code;   }  
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.