Ask Your Question

Revision history [back]

OpenCV's contours will work if you filter the contours by aspect ratio. In the image below the 2nd from the left is thresholded at about 150 using binaryInverse type thresholding. There is a function called boundingRect that will give the upright rect of a contour. Define the contour aspect ratio as rect.width / rect.height and only keep contours with AR < 1 since numbers are tall. This gives the 3rd image from the left. The last is just inverted.

image description