@xyz said:
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
Thank you for this. I think I have a pretty good approximation.
h6 & h7 will have to be assumed to be 0.
Since the true image is rectangle, we can assume that x0, y0, x2, and y1 are all 0.
The remaining x, y, u, and v values are not 0 but are known.
We can solve for the h values in order with basic math, since there is only one unknown in each.
h2 =u0,
h5 =v0,
h0 = (u1 - h2)/x1
h3 = (v1 - h5)/x1
h1 = (u2 - h2)/y2
h4 = (v2 - h5)/y2
I believe this means that I can write a basic Godot function for this approximation. The only error is coming from assuming that h6 and h7 are 0. But I don't think the effect will be very significant in my case.