Question

Does anyone know of a c++ library for taking an image and performing image recognition on it such that it can find letters based on a given font and/or font height? Even one that doesn't let you select a font would be nice (eg: readLetters(Image image).

Was it helpful?

Solution

I've been looking into this a lot lately. Your best is simply Tesseract. If you need layout analysis on top of the OCR than go with Ocropus (which in turn uses Tesseract to do the OCR). Layout analysis refers to being able to detect position of text on the image and do things like line segmentation, block segmentation, etc.

I've found some really good tips through experimentation with Tesseract that are worth sharing. Basically I had to do a lot of preprocessing for the image.

  1. Upsize/Downsize your input image to 300 dpi.
  2. Remove color from the image. Grey scale is good. I actually used a dither threshold and made my input black and white.
  3. Cut out unnecessary junk from your image. For all three above I used netbpm (a set of image manipulation tools for unix) to get to point where I was getting pretty much 100 percent accuracy for what I needed.

If you have a highly customized font and go with tesseract alone you have to "Train" the system -- basically you have to feed a bunch of training data. This is well documented on the tesseract-ocr site. You essentially create a new "language" for your font and pass it in with the -l parameter.

The other training mechanism I found was with Ocropus using nueral net (bpnet) training. It requires a lot of input data to build a good statistical model.

In terms of invoking Tesseract/Ocropus are both C++. It won't be as simple as ReadLines(Image) but there is an API you can check out. You can also invoke via command line.

OTHER TIPS

While I cannot recommend one in particular, the term you are looking for is OCR (Optical Character Recognition).

There is tesseract-ocr which is a professional library to do this.

From there web site

The Tesseract OCR engine was one of the top 3 engines in the 1995 UNLV Accuracy test. Between 1995 and 2006 it had little work done on it, but it is probably one of the most accurate open source OCR engines available

I think what you want is Conjecture. Used to be the libgocr project. I haven't used it for a few years but it used to be very reliable if you set up a key.

The Tesseract OCR library gives pretty accurate results, its a C and C++ library. My initial results were around 80% accurate, but applying pre-processing on the images before supplying in for OCR the results were around 95% accurate. What is pre-preprocessing:

1) Binarize the bitmap (B&W worked better for me). How it could be done

2) Resampling your image to 300 dpi

3) Save your image in a lossless format, such as LZW TIFF or CCITT Group 4 TIFF.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top