开发者

Mapping of 2D Points to a new Perspective

开发者 https://www.devze.com 2023-03-06 23:18 出处:网络
This is my first post! I\'m trying to make an application that can determine whether certain points in a grid (image) are light or dark.The original grid is well defined (I know where all the points

This is my first post!

I'm trying to make an application that can determine whether certain points in a grid (image) are light or dark. The original grid is well defined (I know where all the points should be relative to the corners). Once I know where the point is supposed to be, I can easily tell whether it is light or dark.

The problem is, I'd like to do this from an image of the grid taken from a hand-held camera. Clearly, due to hand movement, the perspective will change, and I'll need to do some math to figure out the location of the new points relative to the corners (I know how to detect the corners).

I've read in other postings that the only properties that are preserved during a transformation are the cross-ratio and incidence. Specifically, this posting put me in the right direction, but the author didn't finish the math. Note that in this example, the author is going from the skewed perspective to the birdseye view, and I'm trying to do the opposite. The math should be the same, though.


From the posting Projective transformation

(So apparently I can't post images because I'm new but the image is on the above post)

1)Find the point C' at the intersection of the lines defined by the segments AD and CP.

2)Find the point B' at the intersection of the lines defined by the segments AD and BP.

3)Determine the cross-ratio of B'DAC', i.e. r = (BA' * DC') / (DA * B'C').

4)Construct the projected line F'HEG'. The cross-ratio of these points is equal to r, i.e. r = (F'E * HG') / (HE * F'G').

5)F'F and G'G will intersect at the projected point Q so equating the cr开发者_Go百科oss-ratios and knowing the length of the side of the square you can determine the position of Q with some arithmetic gymnastics.


My question is step 4, Constructing the line F'HEG'. Is it possible to construct a line of 4 points just knowing 2 points and the desired cross ratio? I feel like that's 1 equation with 2 unknowns.

If someone could help me I will be very grateful!

Sorry that was so long,

Rob

PS I would have just posted on that forum but this is my first post so I don't have permission yet.


If you know the positions of any 4 2D point (no 3 of which lie on the same line), e.g. your corners, you can find the Homography transformation H between your 2D image and the webcam frame.
H is a 3x3 matrix that can convert any point in your frame to the 2D image. The points p are written in homogenious coordinates: [x,y,1] such that p'=Hp.
Given 4 corresponding points in the image and the frame you can solve for the 9 elements of H.


Since F', H, E and G lie on a line in 2D space your problem is very constrained from the start. The unknowns you have are:

  1. Some support point (a point that you know the line passes through), use the first point for this.
  2. The direction of the line (where does it go from the support. You use the direction from the first to the second point for this)
  3. The positions of the points along that line. You have two already (the two points), so you just need two more numbers.

The desired cross ration is actually two equations (one each for the x- and y-coordinate) so you have two equations and two unknowns.

0

精彩评论

暂无评论...
验证码 换一张
取 消