AR app: Mapping 3D object to 2D plane?

I'm trying to create an Augmented Reality app. I'm using OpenCV to get 4 points from a checkerboard pattern that represent the four corners of the pattern. This should be used to create a plane in my app, but the points are in 2D.

Anyone here have an idea how one is to use these 4 points to create a plane and/or map a 3D object to the pattern

-
I'm not an expert in 3D math unfortunately so I can't give an exact answer, but I think the solution will involve something like creating vectors out of lines connecting those points and using the cross product of those vectors to determine the orientation of the plane. Refer here: blog.wolfire.com/2009/07/… – jhocking Apr 18 '11 at 21:37

Having found the corners in 2D, you assign them 3D coordinates yourself. (You might know the actual physical size of the board squares, or you might simply do everything relative to these sizes e.g. assign them a size of 1).

You then calibrate the camera giving the chessboard positions and your assigned 3D coordinates. OpenCV then computes a camera model. With this camera model, you can project 3D points.

There is a good example in Tutorial 10. This also shows how to undistort the image.

-

There was a question on Stack Overflow that also has a link to the ARToolkit which describes the process they use a little bit.

-

So, haven't tried this before, but here is my guess at the approach.

You've got four points in screen space, in 2D. Let's refer to those as the UL,UR,LL,LR corner points (upper left, upper right, etc.).

Create a vector from the LL to the UL (so, along the left edge), and another vector from the LL to the LR (along the bottom edge). The cross product of these two vectors (with normalization applied where needed) give you the normal of the plane for the checkerboard.

You've still got to figure out the distance of the plane from the camera; to do this, you need to figure out how the edge distances compare with what you believe they should be, and so back out the perspective scaling that's been undergone. To get a feel for the scales, you'll probably need a calibration phase for your code where you place the checkerboard facing the camera straight on (perpendicular to the camera) and move it to different (measured and known!) distances, observing the detected lengths of the edges. From that information you can figure out the perspective transform of the camera.

That should be a good start, anyways.

Update

I made a mistake here and failed to address that the actual depth of the points/vectors would still need to be worked out. The cross-product as spec'd above would be useless, as it could only give you a vector perp. to the camera, which is useless.

I'm leaving this up in case it spurs any ideas, but the approach I quickly sketched is, at best, deeply flawed.

-
Won't the vectors LL,UL and LL,LR need to be perpendicular to each other( 90 degree angle ) in order for the cross product to give the normal to the plane? In 3D space they are, but in 2D space they are not. I could be wrong though. – Joey Green Apr 19 '11 at 0:18
They don't need to be perpendicular but your real problem is that getting the vectors for the edges (3D vectors that is) is not addressed at all by Chris' answer and that task will probably be tricky. – jhocking Apr 19 '11 at 0:56
@Joey: Gah, absolutely correct--looks like my brain shut off. I was answering this as I left work; mea culpa. Updated answer to reflect this. – ChrisE Apr 19 '11 at 1:03