Do you know what size of the desired rectangle is? You can map any convex quadrangle to a rectangle with a reversible transform with a perspective transform, if so. All you have to do is get 4 corresponding points (between the quad and the rectangle), say, (X 1 , Y 1 ), (X 2 , Y 2 ), (X 3 , Y 3 ), (X 4 , Y 4 ) for a quadrangle and (x 1 , y 1 ), (x 2 , y 2 ), (x 3 , y 3 ), (x 4 , y 4 )) for a rectangle, respectively. Then connect it to the final equation in the Borealid link and you will set:

The solution to the above equation (where n = 4) will give you the elements (a, b, c, d, e, ..., h) of the matrix of reversible perspective transformations,

This will allow you to convert points on a rectangle to points on quadrangles. For the inverse transform, just invert the transform matrix.
Also note that as soon as you get the transformed coordinates of the vector [XW YW W] T, you need to normalize it so that W = 1. That is, Your final answer will be [XW ββ/ W YW / WW / W] T which equals [XY 1] T the desired answer.
Jacob
source share