OpenCV minAreaRect for character

I am implementing a system that must recognize characters before recognition. I am currently using OpenCV minAreaRect to get the best rectangle that contains a character. I am using these coordinates of the rectangle to apply the warpPerspective transform, so it needs to be accurate.

The problem is that for some characters, this minAreaRect does not return the best position for characters as shown here: http://i.stack.imgur.com/1ibxi.png Note that the red outlines represent the minArea rectangle and the green one is the circuit itself.

I tried to check the area of ​​the T field and it seems to be like a rectangle containing T. Is this the expected behavior of this function?

+3


source to share


1 answer


Unfortunately, this is common behavior for minAreaRect()

. You will also face this issue with 7 for example. A common solution to this problem is to search for baseline characters.



An easy way to do this is to iterate over your objects rotatedRect

and keep the angles on the shortest sides and sizes. Then place the rotatedRect

most common angle and size and replace the outliers with that.

+2


source







All Articles