# Given the 4 corners of two QR codes on a photographed sheet of paper, can we get a deskewed rectangular image?

I made a photo of 2 sheets of paper with a phone camera, each of them cropped at the:

• (x1, y1) top left corner of top QR code
• (x2, y2) bottom right corner of bottom QR code

I hoped that the x, y coordinate of checkboxes would be nearly the same. In fact it's not, because of the angle of the camera, skewness, etc.

Question: How to have a better deskewing by using 8 corners:

• the 4 corners of top QR code (detected automatically by this method): (x1, y1), ..., (x4, y4)
• the 4 corners of bottom QR code: (x5, y5), ..., (x8, y8)

?  Note: links of the 2 images: https://i.stack.imgur.com/SR8hz.jpg and https://i.stack.imgur.com/XsxrT.jpg

• You want to find a "homography", or a linear transform that takes a point in one plane (image) and maps it onto another. Assuming the paper is not bent in anyway, we can assume that all points on the paper are coplanar. You can compute the homography between 4 corresponding points, (ie. all four corners of the top left QR code), and use that to find the corresponding point in one image, given the other (homographies are invertible). Here's how to compute the homography – Carpetfizz May 20 '18 at 22:40