Using findHomography to align scanned documents; How do I avoid obviously-bad (non-planar/3D) transforms?
We have hundreds of scanned copies of a form; We need to align each image to a template, correcting for translation and rotation in 2-Dimensions.
After trying some FFT-based methods, we've gotten our best results using OpenCV to do the alignment as described in the article Image Alignment (Feature Based) using OpenCV.
When it works, it works perfectly. But often it produces very strange results.
Sometimes the results are moderately skewed into the 3rd Dimension, but usually the bad alignments are ridiculous to the point of resembling abstract art.
Is there a way to constrain findHomography to only planar results? If not, is there a way to detect non-planar results in findHomography's output?
Screenshots below, the blue regions are my redactions.
Can you add the original images?
How the scanned documents look like? If the document is fully visible, I would instead try to detect the 4 corners (e.g. using the contours, using lines detection and lines intersection ) and estimate the homography on these corners.
Unfortunately, the corners are usually completely invisible -- but not always.
I would try something like line detection to get the orientation of the sheet since you should get only in-plane rotation if you are using a scanner.