View Single Post
  #2  
Old July 4th, 2009, 09:15 PM
alunw's Avatar
alunw alunw is offline
Member
 
Join Date: May 2009
Posts: 185
Country:
Thanks: 9
Thanked 48 Times in 43 Posts
alunw will become famous soon enough
Default

I'm assuming you are working with 2D coordinates using 3D inhomogeneous coordinates (so that the point (x,y) is represented (x,y,1))
There is exactly one projective transformation between two sets of 4 non-collinear points.
It is slightly laborious to calculate this transformation but not difficult: one way is to first
calculate the transformation that sends the four points (1,0,0) (0,1,0) (0,0,1) and (1,1,1) to the first set of points, and then the transformation that sends the same four points to the second set of points. Then the transformation you want is the inverse of the first multiplied by the second.

To send the four reference points to (x1,y1,z1),(x2,y2,z2),(x3,y3,z3),(x4,y4,z4)

write down the matrix M=x1 x2 x3
y1 y2 y3
z1 z2 z3

Calculate M^-1*(x4,y4,z4) (regarding this point as a column vector)
Suppose this gives you the point (a,b,c)
write down the matrix N = a/c 0 0
0 b/c 0
0 0 1
The matrix of the transformation is M*N
Since the polygon you are calculating probably has four vertices you can easily calculate the transformation that the projector has made to your image. If you apply the inverse transformation to your image coordinates first then this will undo the distortion. However you might need to scale your image down first slightly.
Reply With Quote