A word of warning about solutions to this problem. The &quot;easy&quot; version states it this way: the mapping you want takes (x,y) to ((ax+by+c)&#x2F;(gx+hy+i),(dx+ey+f)&#x2F;(gx+hy+i)) for some a,b,c,d,e,f,g,h,i -- a general &quot;projective transformation&quot;. If you decide ahead of time exactly what rectangle you want to map to, you have 8 constraints on a..i (two coordinates for each of four corners) and one irrelevant degree of freedom (if you multiply all of a..i by the same constant, nothing changes) so you have &quot;exactly enough&quot; information to find those parameters. So you solve the equations and you&#x27;re done.<p>This works, provided your measured positions are perfectly accurate, but it isn&#x27;t the best you can do. The reason is that a single projection actually has one degree of freedom less than a general projective transformation. (Three parameters to say where your camera is located. Three to say how it&#x27;s rotated. One scaling factor. Total is 7 rather than 8.) This means that there&#x27;s an extra (slightly hairy) constraint on the parameters a..i, which turns out to mean that the aspect ratio of the rectangle you&#x27;re mapping to is determined for you.<p>Imposing that constraint will give you (1) more information -- you won&#x27;t have to know ahead of time what aspect ratio you have -- and (2) a more accurately estimated transformation.<p>You can find more details of this stuff in, e.g., this PDF document: <a href="http:&#x2F;&#x2F;people.csail.mit.edu&#x2F;bkph&#x2F;articles&#x2F;Harmful.pdf" rel="nofollow">http:&#x2F;&#x2F;people.csail.mit.edu&#x2F;bkph&#x2F;articles&#x2F;Harmful.pdf</a> .