This simple code has been developed during the PIV (Image Processing) course @IST Lisboa.
The aim is to determine the homography between a sheet distorted by perspective and a view from above. The homography is determined manually, without using OpenCV. However, OpenCV is used for display purposes and to apply the homography once determined.
The first part consists in getting the 4 key points of the sheet. These coordinates will be considered as being part of the initial picture frame.
Then, we declare our final frame, by choosing the size of the input image (example here, should fit the sheet format). Hence, the sheet will fill the entire output image.
The mathematical part follows. We build the correpondance point matrix
Then, the homography h is given by solving
OpenCV is again used to apply the homography, and write the output image.
The 4 points have been places at the 4 corners of the iPad, here is the result:
Input image | Output image |
---|---|