Ask Your Question

Revision history [back]

What is the purpose of your code? It working, right? When @StevenPuttemans has you some code, he means not working code, not the one you have done that is working.

I assume "correction" mean find lines and rotate the scanned page? If you want to detect lines, I've read long time ago an article doing this very simply: compute histogram by row in your image. The row with "many" white pixels are the one with text, the other are the white line between two line of text.

After that, you could approximate the angle using the histogram distribution by line: as you goal is to have right line, apply an angle to a line of text. Compute the new histogram. See if it is closer to an "ideal" distribution, something that have an high peak in the center and high decrease to both side.

My solution is highly experimental, and many many many others solution should have been apply for text recognition! Google it, try some, and if you have some trouble to implement it with OpenCV, ask here.