Scoreboard digit recognition using OpenCV

pyromanfo picture pyromanfo · Nov 9, 2011 · Viewed 7.3k times · Source

I am trying to extract numbers from a typical scoreboard that you would find at a high school gym. I have each number in a digital "alarm clock" font and have managed to perspective correct, threshold and extract a given digit from the video feed

Sample input

Here's a sample of my template input

Template input

My problem is that no one classification method will accurately determine all digits 0-9. I have tried several methods

1) Tesseract OCR - this one consistently messes up on 4 and frequently returns weird results. Just using the command line version. If I actually try to train it on an "alarm clock" font, I get unknown character every time.

2) kNearest with OpenCV - I search a database consisting of my template images (0-9) and see which one is nearest. I frequently get confusion between 3/1 and 7/1

3) cvMatchShapes - this one is fairly bad, it usually can't tell the difference between 2 of the digits for each input digit

4) Tangent Distance - This one is the closest, but the smallest tangent distance between the input and my templates ends up mapping "7" to "1" every time

I'm really at a loss to get a classification algorithm for such a simple problem. I feel I have cleaned up the input fairly well and it's a fairly simple case for classification but I can't get anything reliable enough to actually use in practice. Any ideas about where to look for classification algorithms, or how to use them correctly would be appreciated. Am I not cleaning up the input? What about a better input database? I don't know what else I'd use for input, each digit and template looks spot on at this point.

Answer

Sam picture Sam · Nov 9, 2011

The classical digit recognition, which should work well in this case is to crop the image just around the digit and resize it to 4x4 pixels.

A Discrete Cosine Transform (DCT) can be used to further slim down the search space. You could select the first 4-6 values.

With those values, train a classifier. SVM is a good one, readily available in OpenCV.

It is not as simple as emma's or martin suggestions, but it's more elegant and, I think, more robust.

Given the width/height ratio of your input, you may choose a different resolution, like 3x4. Choose the smallest one that retains readable digits.