Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

First you need to find transformation from 4 points of source quadrilateral (A, B, C and D) to 4 points of some destination quadrilateral. In your case I guess it will be something like (0,0), (width,0), (width,height), (0,height). You can find them by use of getPerspectiveTransform. Output of getPerspectiveTransform is 3x3 matrix P of perspective transformation of 2D points (in homogeneous coordinates of course). You may apply it to F in order to get the coordinates you need. The calculation is:

Given F=(x,y). Multiply P by (x,y,1). Resulting vector will be (xr,yr,zr). Since this is homogeneous coordinates this is equivalent to (xr/zr, yr/zr, 1). So the coordinate of transformed F is (xr/zr, yr/zr).