Ask Your Question

# Revision history [back]

The function GetPerspectiveTransform calculates the matrix of perspective transformation between srcQuad points and dstQuad points. In other words it calculates coefficients of perspective transformation which maps (xi,yi) to (ui,vi), (i=1,2,3,4):

      c00*xi + c01*yi + c02
ui = ---------------------
c20*xi + c21*yi + c22

c10*xi + c11*yi + c12
vi = ---------------------
c20*xi + c21*yi + c22


Coefficients are calculated by solving linear system:

  / x0 y0  1  0  0  0 -x0*u0 -y0*u0 \ /c00\   /u0\
| x1 y1  1  0  0  0 -x1*u1 -y1*u1 | |c01|    |u1|
| x2 y2  1  0  0  0 -x2*u2 -y2*u2 | |c02|    |u2|
| x3 y3  1  0  0  0 -x3*u3 -y3*u3 |.|c10| = |u3|
|  0  0  0 x0 y0  1 -x0*v0 -y0*v0 | |c11|    |v0|
|  0  0  0 x1 y1  1 -x1*v1 -y1*v1 | |c12|    |v1|
|  0  0  0 x2 y2  1 -x2*v2 -y2*v2 | |c20|    |v2|
\  0  0  0 x3 y3  1 -x3*v3 -y3*v3 / \c21/   \v3/


where: cij - matrix coefficients, c22 = 1

 2 fixed formatting SR 1540 ●1 ●14 ●29

The function GetPerspectiveTransform calculates the matrix of perspective transformation between srcQuad points and dstQuad points. In other words it calculates coefficients of perspective transformation which maps (xi,yi) to (ui,vi), (i=1,2,3,4):

      c00*xi + c01*yi + c02
ui = ---------------------
c20*xi + c21*yi + c22

c10*xi + c11*yi + c12
vi = ---------------------
c20*xi + c21*yi + c22


Coefficients are calculated by solving linear system:

  / x0 y0  1  0  0  0 -x0*u0 -y0*u0 \ /c00\    /u0\
| x1 y1  1  0  0  0 -x1*u1 -y1*u1 | |c01|    |u1|
| x2 y2  1  0  0  0 -x2*u2 -y2*u2 | |c02|    |u2|
| x3 y3  1  0  0  0 -x3*u3 -y3*u3 |.|c10| =  |u3|
|  0  0  0 x0 y0  1 -x0*v0 -y0*v0 | |c11|    |v0|
|  0  0  0 x1 y1  1 -x1*v1 -y1*v1 | |c12|    |v1|
|  0  0  0 x2 y2  1 -x2*v2 -y2*v2 | |c20|    |v2|
\  0  0  0 x3 y3  1 -x3*v3 -y3*v3 / \c21/    \v3/


where: cij - matrix coefficients, c22 = 1