How to use OpenCV+Tesseract for accurate Text reco

2020-02-08 06:46发布

问题:

I am trying to use OpenCV (Android) for processing image taken using camera and then pass it to Tesseract for text (digits) recognition but am not getting good results till the images are very (almost no noise) fine. Currently I am performing below processing on taken images as: 1. Applying Gaussian blur. 2. Adaptive threshold: to binarize the image. 3. Inverting colours to make background black. Then passing the processed image to Tesseract.

But I am not getting good results.

Please suggest what steps/measures I may take further to process image before passing to Tesseract or at stage while processing at Tesseract.

Also, are there any other better libraries in Android for this?

回答1:

You can isolate/detect characters in images. This can be done with powerful algorithms such as the Stroke Width Transform.

The following steps worked well with me:

  1. Obtain grayscale of image.
  2. Perform canny edge detection on grayscale image.
  3. Apply gaussian blur on grayscale image(store in seperate matrix)
  4. Input matrices from steps 2 & 3 into SWT algorithm
  5. Binarize(threshhold) resulting image.
  6. Feed image to tesseract.

Please note, for step 4 you will need to build the c++ library in the link and then import into your android project with JNI wrappers. Also, you will need to do micro tweaking for all steps to get the best results. But, this should at least get you started.