Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCR on text stamped into metal plate

I am working on an OCR project whose goal is to read the stamped-in serial number off of a metal plate:

Example of stamped text.

I am using OpenCV to prepare the image for OCR, and using Tesseract for the OCR itself. This is the ideal process:

  1. In a picture of the entire plate, crop to the general location of the serial number.
  2. Prepare the cropped image for OCR.
  3. Apply OCR.

My current process is this:

  1. Manually crop to serial number.
  2. Convert to grayscale.
  3. Sharpen.
  4. Use Canny edge detection.
  5. Run Tesseract OCR.

However, I am having very limited success. My main questions are:

  • What sort of processing optimizes OCR? Is doing edge detection a good start?
  • Can I perhaps use the stamped text's font to my advantage?
  • Can I use the "color" of the text (as opposed to the gray of the metal or the black/white of the labels) to my advantage?
like image 234
justgus Avatar asked Jun 17 '15 18:06

justgus


1 Answers

I feel this isn't the complete solution may be but can help -

I have been working on a similar scenario where i wanted to extract text from embossed metal.

My approach is similar to your approach -

  1. Read the image
  2. Convert it to grayscale
  3. Canny edge detection
  4. Dilation
  5. Finding contours and removing unnecessary noice
  6. again dialation if necessary
  7. Invert thresholding
  8. Tesseract

What i have noticed is Tesseract works better when the color of text is black and background is white.(So, i am doing the 7th step)

You can see the code and results of my work here - https://github.com/DevashishPrasad/Embossed-Text-Reader

And i would also like to mention that it all depends on canny and your image. You keep threshold values low to find more edges and high to find less edges. But more edges introduce noise in the image while less edges would fail to detect whole digit. So it all depends on the canny threshold values and your image.

like image 60
Devashish Prasad Avatar answered Sep 21 '22 03:09

Devashish Prasad