Tulon wrote:Rob, I think RANSAC should work really well for selecting two representative lines. You basically pick two at random, build a distortion model based on them and check how well other lines fit into that model. Repeat the process a number of times and go with the best attempt. What do you think?
I didn't realize it at the time, but I used a RANSAC algorithm to choose lines for dekeystoning in my original program. It seemed to work very well, so it might be a good idea to consider.
I think what I did was generate vertical margins based on the topmost longest and bottommost longest lines, then checked all the lines to make sure that they did not go too far outside
or too far inside those margins. (I emphasize too far inside because I assumed a uniform block of text) If a line did, remove it, and try again until a good fit is obtained. "Topmost" and "bottommost" didn't mean the absolute top and bottom line, but any line in the top 1/3 of the page, and any line in the bottom 1/3 of the page. The algorithm is more heuristic than anything else.
One other thing I'm considering -- a preprocessor which uses a checkerboard pattern to correct for keystoning (but not for warping). The idea would be that you could place a checkerboard on top of the platen every so often. After all your images are taken, a preprocessor program would run through the images, and if it detects a checkerboard, detect the corners of the checkerboard, compute a dekeystoning matrix, and correct any following images.
I had originally thought that the dekeystoning could be applied more smoothly by interpolating between checkerboard pages, but then I realized that any time you changed the location, orientation, or zoom of the camera, you would have to insert a checkerboard which would only be valid for the next pages, not the previous pages.
Now, OpenCV has all this code built in. And it's C. You might be able to add the OpenCV library to Scan Tailor and do this within Scan Tailor, but I could probably write a standalone program that could be run before ST, to give ST an easier time with the images.
Anyway, those are some random thoughts.