I'm working on a little project that does "scan" sheets of paper using a camera (specifically the iPhone camera).
Workflow:
Lets users take pictures of sheets of paper while I will afterwards detect corners/the outline so I know the 4 corner points of the original sheet of paper in the photograph. It is then easy to inverse the perspective transformation of the camera to gain a "flat" image of the photographed sheet of paper.
However, my question is: how do I maintain or even calculate the correct (original) aspect ratio?
As you can see above I have the coordinates for the corner points and I also know how to construct a matrix to map the top left corner to the point (0,0), the top right corner to (width,0), the bottom right corner to (width, height) and the bottom left corner to (0,height).
The question now is: How do I get the correct width/height aspect ratio the sheet of paper originally has. I'm pretty sure I can figure it out using the angles to determine the perspective transformation but I'm stuck finding the right formula. I also have a hunch that I also would need the focal length of the camera but it would be great not to need that.
Any ideas would be appreciated.