In my experience, OCR libraries tend to merely output the text found within an image but not where the text was found. Is there an OCR library that outputs both the words found within an image as well as the coordinates (x, y, width, height
) where those words were found?
Create a Python tesseract script Create a project folder and add a new main.py file inside that folder. Once the application gives access to PDF files, its content will be extracted in the form of images. These images will then be processed to extract the text.
Tesseract tests the text lines to determine whether they are fixed pitch. Where it finds fixed pitch text, Tesseract chops the words into characters using the pitch, and disables the chopper and associator on these words for the word recognition step.
While Tesseract is known as one of the most accurate free OCR engines available today, it has numerous limitations that dramatically affect its performance; its ability to correctly recognize characters in a scan or image.
Tesseract is an optical character recognition engine for various operating systems. It is free software, released under the Apache License.
Most commercial OCR engines will return word and character coordinate positions but you have to work with their SDK's to extract the information. Even Tesseract OCR will return position information but it has been not easy to get to. Version 3.01 will make easier but a DLL interface is still being worked on.
Unfortunately, most free OCR programs use Tesseract OCR in its basic form and they only report the raw ASCII results.
www.transym.com - Transym OCR - outputs coordinates. www.rerecognition.com - KADMOS engine returns coordinates.
Also Caere Omnipage, Mitek, Abbyy, Charactell return character positions.
I'm using TessNet (a Tesseract C# wrapper) and I'm getting word coordinates with the following code:
TextWriter tw = new StreamWriter(@"U:\user files\bwalker\ocrTesting.txt"); Bitmap image = new Bitmap(@"u:\user files\bwalker\2849257.tif"); tessnet2.Tesseract ocr = new tessnet2.Tesseract(); // If digit only ocr.SetVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,$-/#&=()\"':?"); // To use correct tessdata ocr.Init(@"C:\Users\bwalker\Documents\Visual Studio 2010\Projects\tessnetWinForms\tessnetWinForms\bin\Release\", "eng", false); List<tessnet2.Word> result = ocr.DoOCR(image, System.Drawing.Rectangle.Empty); string Results = ""; foreach (tessnet2.Word word in result) { Results += word.Confidence + ", " + word.Text + ", " +word.Top+", "+word.Bottom+", "+word.Left+", "+word.Right+"\n"; } using (StreamWriter writer = new StreamWriter(@"U:\user files\bwalker\ocrTesting2.txt", true)) { writer.WriteLine(Results);//+", "+word.Top+", "+word.Bottom+", "+word.Left+", "+word.Right); writer.Close(); } MessageBox.Show("Completed");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With