How to implement and do OCR in a C# project?

前端 未结 4 1953
清歌不尽
清歌不尽 2020-12-07 09:12

I ve been searching for a while and all that i ve seen some OCR library requests. I would like to know how to implement the purest, easy to install and use OCR library with

4条回答
  •  一个人的身影
    2020-12-07 09:38

    I'm using tesseract OCR engine with TessNet2 (a C# wrapper - http://www.pixel-technology.com/freeware/tessnet2/).

    Some basic code:

    using tessnet2;
    

    ...

    Bitmap image = new Bitmap(@"u:\user files\bwalker\2849257.tif");
                tessnet2.Tesseract ocr = new tessnet2.Tesseract();
                ocr.SetVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,$-/#&=()\"':?"); // Accepted characters
                ocr.Init(@"C:\Users\bwalker\Documents\Visual Studio 2010\Projects\tessnetWinForms\tessnetWinForms\bin\Release\", "eng", false); // Directory of your tessdata folder
                List result = ocr.DoOCR(image, System.Drawing.Rectangle.Empty);
                string Results = "";
                foreach (tessnet2.Word word in result)
                {
                    Results += word.Confidence + ", " + word.Text + ", " + word.Left + ", " + word.Top + ", " + word.Bottom + ", " + word.Right + "\n";
                }
    

提交回复
热议问题