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 cross-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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With