Look into ML for page match transform
We do a whole bunch of stuff at the moment to attempt to line up our template and scanned pages, mostly derived from trial and error as I'm not a computer image scientist and have very little experience with OpenCV.
It may be possible to do a little bit of ML for this. We know the positions and sizes of our triangles, and ultimately want to find a perspective transformation that will yield our triangles lining up correctly.
So we'd have IN: Triangle Data + Pixel Data, OUT: Perspective Transformation Matrix
It should be possible to generate large training sets by applying noise and arbitrary transformations to generated images. Please note I have a very loose understanding of ML at this point, so can't confirm the viability of this idea.
Edited by Mirko Vucicevich