User`s manual
151 cur_state <= ~OVERRIDE;
152 end
153 end
154
155 endmodule
A.3.10 perspective params.v
1 ///////////////////////////////////////////////////////////////////////////////////////////////////
2 // perspective_params: Generate the parameters for the perspective transform from the
3 // rectangle to the quadrilateral inside it
4 // Note that this is the forward mapping
5 // The math is described as follows
6 // Let (x1, y1), (x2, y2), (x3, y3), (x4, y4) be the four points inside the
7 // screen
8 // Let the (forward) perspective map be given by:
9 // (X, Y) = ((p1*x + p2*y + p3)/(p7*x + p8*y + p9), (p4*x + p5*y + p6)/(p7*x
10 // + p8*y + p9))
11 // Then our task is to determine the values of p_i given the values of the x_i
12 // This is a system of equations in 8 unknowns
13 // It turns out that a pretty simple closed form solution exists, given by
14 //
15 // p7 = 3((x1-x4)(y2-y3) + 3(y1-y4)(x3-x2))
16 // p8 = 4((x1-x2)(y3-y4) + 4(x4-x3)(y1-y2))
17 // denom = x4(y2-y3) + x2(y3-y4) + x3(y4-y2)
18 // p9 = 1920*denom (2^7 * 15 * denom)
19 // p3 = 1920*x1*denom (2^7 * 15 * x1 * denom)
20 // p6 = 1920*y1*denom (2^7 * 15 * y1 * denom)
21 // p1 = x4*p7 + 3(x4-x1)*denom
22 // p2 = x2*p8 + 4(x2-x1)*denom
23 // p4 = y4*p7 + 3(y4-y1)*denom
24 // p5 = y2*p8 + 4(y2-y1)*denom
25 //
26 // inverse mapping
27 // p1_inv = p6*p8 - p5*p9
28 // p2_inv = p2*p9 - p3*p8
29 // p3_inv = p3*p5 - p2*p6
30 // p4_inv = p4*p9 - p6*p7
31 // p5_inv = p3*p7 - p1*p9
32 // p6_inv = p1*p6 - p3*p4
33 // p7_inv = p5*p7 - p4*p8
34 // p8_inv = p1*p8 - p2*p7
35 // p9_inv = p2*p4 - p1*p5
36 // dec_numx_horiz = p1_inv * 639
37 // dec_numy_horiz = p4_inv * 639
38 // dec_denom_horiz = p7_inv * 639
227