OCR engine OCR (Optical Character recognition) refers to the use of scanners or digital cameras to scan text data into image files, and then the image file analysis and processing, automatically identify the acquisition of text information and layout information software. The core technology module of OCR engine is composed of the following parts: Image input: The algorithm of reading different image format files. Image preprocessing: Mainly including image binary, noise removal, tilt, and other algorithms layout analysis: The document picture is divided into paragraphs, the algorithm of the branch is called the layout analysis algorithm character cutting: The character cutting algorithm mainly handles the character adhesion, the broken pen causes the character to be difficult to cut the question easily. Character feature extraction: The character image extraction multidimensional features are used in the following feature matching pattern recognition algorithm. Character recognition: The feature vector extracted from the current character and the feature template Library are coarse-grained and template-fine-matched to identify the algorithm of character. Layout recovery: To identify the original document layout, according to the original layout format to export the recognition results to Word or PDF format documents, called the layout recovery algorithm. Post-processing correction: A more positive algorithm for recognition results based on the relationship of a particular language context.
Among them, for. NET three kinds of more mainstream and mature recognition methods:
Method One, Asprise OCR implementation. The 3 DLLs that need to be used are AspriseOCR.dll, DevIL.dll, ILU.dll. Its digital recognition rate is higher,
Example code:
[DllImport ("AspriseOCR.dll")] Static extern stringCRABOOCR (stringFileinttype);Private voidGetveryfycode () {if(File.exists (_imgpath))//OK { Try { This. picbveryfycode.image=System.Drawing.Bitmap.FromFile (_imgpath); _veryfycode=CRABOOCR (_imgpath,-1);//will return a string and end with "\ r \ n" !_veryfycode=_veryfycode.substring (0,4); This. txtveryfycode.text=_veryfycode; } Catch(Exception e) { This. lblresult.text+=E.message; } }}
Way two, Microsoft office Document Imaging (Office 2007) components are implemented.
Mode three, Tesseract engine, its. NET version address is: http://www.pixel-technology.com/freeware/tessnet2/. Where the engine is to be installed before it is used, the DOS command line can be encapsulated after successful installation.
The invocation command form is as follows:
Private voidUSEOCR (stringV_strtesseractpath,stringV_strsourceimgpath,stringV_stroutputpath,stringV_strlangpath) { using(Process process =NewSystem.Diagnostics.Process ()) {process. Startinfo.filename=V_strtesseractpath; Process. Startinfo.arguments= V_strsourceimgpath +" "+ V_stroutputpath +"- L"+V_strlangpath; Process. Startinfo.useshellexecute=false; Process. Startinfo.createnowindow=true; Process. Startinfo.redirectstandardoutput=true; Process. Start (); Process. WaitForExit (); } }
Image text recognition