Ok so here's the system of equations that needs to be solved
x0h0 + y0h1 + h2 - u0x0h6 - u0y0h7 = u0
x0h3 + y0h4 + h5 - u0x0h6 - u0y0h7 = v0
x1h0 + y1h1 + h2 - u1x1h6 - u1y1h7 = u1
x1h3 + y1h4 + h5 - u1x1h6 - u1y1h7 = v1
x2h0 + y2h1 + h2 - u2x2h6 - u2y2h7 = u2
x2h3 + y2h4 + h5 - u2x2h6 - u2y2h7 = v2
x3h0 + y3h1 + h2 - u3x3h6 - u3y3h7 = u3
x3h3 + y3h4 + h5 - u3x3h6 - u3y3h7 = v3
where:
x, y are coordinates of original points
u, v are coordinates of distorted points
h0-h7 are variables you need to solve for, these then go directly into the matrix
If you have Mathematica or Pro account at WolframAlpha, you can just paste:
solve
x0h0+y0h1+h2-u0x0h6-u0y0h7=u0,
x0h3+y0h4+h5-u0x0h6-u0y0h7=v0,
x1h0+y1h1+h2-u1x1h6-u1y1h7=u1,
x1h3+y1h4+h5-u1x1h6-u1y1h7=v1,
x2h0+y2h1+h2-u2x2h6-u2y2h7=u2,
x2h3+y2h4+h5-u2x2h6-u2y2h7=v2,
x3h0+y3h1+h2-u3x3h6-u3y3h7=u3,
x3h3+y3h4+h5-u3x3h6-u3y3h7=v3
for h0,h1,h2,h3,h4,h5,h6,h7