O'Reilly logo

Learn OpenCV 4 by Building Projects - Second Edition by Prateek Joshi, Vinicius G. Mendonca, David Millan Escriva

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Text extraction

Now that we have detected the regions, we must crop the text before submitting it to the OCR. We could simply use a function like getRectSubpix or Mat::copy, using each region rectangle as a region of interest (ROI) but, since the letters are skewed, some undesired text may be cropped as well. For example, this is what one of the regions would look like if we just extract the ROI based on its given rectangle:

Fortunately, ERFilter provides us with an object called ERStat, which contains pixels inside each extremal region. With these pixels, we could use OpenCV's floodFill function to reconstruct each letter. This function is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required