1

I am new to image processing and to opencv in particular.

I am working on an OCR project in which i need to identify numbers.

This is my image to process:

co

Lets say i already optimized the image, my questions are:

  1. In the image the number are always apeared several times, lets say i found the contours, so how can i know which one if the the best one to process?

  2. How can I know in what angle I need to rotate each contour to make It stright?

omriman12
  • 1,439
  • 3
  • 23
  • 42

2 Answers2

1

In the image the number are always apeared several times, lets say i found the contours, so how can i know which one if the the best one to process?

You want always the biggest number, because they are least warped by perspective. So you always want the numbers in the middle of the image, because they are also n the middle of the ball.

How can I know in what angle I need to rotate each contour to make It stright?

Have a look at rotated rect. I explained how to find the angle in this thread.

Since you always have a perfectly centered ball, you should think about using mapping to "unwarp" your ball (so do a projection like from the globe onto a map). It should be pretty straightforward afterwards to find the numbers on the flat image.

Edit: Since you only have 10 numbers you might also "brute force" the solution with a big enough training set. So just throw all numbers you detect into a classifier and keep the most likely solution.

Community
  • 1
  • 1
Sebastian Schmitz
  • 1,772
  • 2
  • 19
  • 40
1

1) I agree with @Sebastian in the first part. Exploit the fact that in your scenario the numbers are placed in the surface of a ball, so first select the blobs inside a centered region of interest.

2) The contours shown in the image are not rotated (the numbers are). Instead of "rotating" these bounding boxes, which seems to be quite a headache, I'd rather use them combined with rotation invariant keypoints. I'll clarify this:

a) You know where your numbers are, so you don't have to search in the entire image. OK, keep these already selected regions in mind.

b) You can take "straight" samples of the numbers 0-9 and use them as ground truth.

c) You can perform a matching search between each "ground truth" image and each candidate region. Now, forget the scale/rotation: use scale/rotation invariant keypoints! Something like this: enter image description here Again, notice that you have already selected the region-of-interest, so in your case the search will consist on checking the number of matches (number of blue lines) between each of the registered numbers and your candidate. I think it worth a try! :)

You can find more info on the different keypoints available in opencv here.

Hope that it helps!

Яois
  • 3,563
  • 3
  • 21
  • 46