   Extracting rotations from a 2D Square
  I am working on an augmented reality project with OpenGL and OpenCV and I hit a wall. Tracking the marker works great and i have 4 points of my marker square. The problem is that I am not sure how to convert the information in the image into x and z rotations.Just for reference, the Y axis is perpendicular to the plane that the marker is laying on (in this case my kitchen table).this is how i have been calculation the Y axis...1. take two vectors2. normalize3. dot product4. y rotation = (internal angle - 180) / 2How would I calculate the other two rotations?Thanks   
  Can you attach an illustration, to clarify what you have and what you're looking for?   ;  this is the best picture i have found to describe what i am talking about.the image from the camera is my "image plane".  that only gives me a X and Y coordinates.  i need to figure the depth of a point so i have a 3D point in space.The end state is put a 3D image on top of the image plane and have them line up (as illustrated by the below picture).;  That illustration is perfect, thank you. Let me think about it. Maybe some other people will also reply.   ;  Here's an idea I'm thinking about. I'm going to ignore perspective and just assume you have an orthographic camera...not true in reality but if you know about the lens of the camera you can take the image space points and remove the perspective, then run through this idea. So, here's the idea.(I apologize that I don't have time to make an illustration, especially after asking you to make one. But, alas, I do not.)So, your image space quad has 4 edges. Lets name your edges a, b, c, and d. Those edges are sequential as you walk around the quad, so a leads to b leads to c leads to d. The edges are the vectors that connect the vertices of the quad, so a goes from vertex 0 to vertex 1, b goes from vertex 1 to vertex 2, and so on.With the 4 points, you can compute the image space versions of the edges, as defined above. Lets represent them as 3D vectors. You know the x and y coordinates, but not image space z. So, with 4 image space edges, you have 4 unknowns. Here's what your image space vectors look like:a = <ax, ay, az_u>and so on. I have subscripted the z coordinate with "_u" to illustrate that we do not know it, and have to solve for it.So, we have 4 unknown values. To find them we need 4 equations. Then we can solve those equations to find the unknown z's. Once we have the unknown z's, then we have full 3D vectors that can be used to find an image space normal to the 3D square. We can also construct a model-to-world or world-to-model matrix to move back and forth. (But...you can't do the translation part of the model-to-world stuff unless you have some way of knowing where one of the points is in world space...you don't know that from the image...so all I am helping with here is getting the normal in image space, ignoring the world space translation issue.)We can exploit the known geometry of the perfect model space square to create the equations. Here is what we know, since the geometry is a square:1) edges a and c are parallel, so their cross product has zero length. This is one equation 1 out of 4 needed.2) edges b and d are parallel, so their cross product has zero length. This is equation 2 out of 4 needed.3) edges a and c have the same length. edges b and   d have the same length.4) The following edge pairs are perpendicular.   a and b   a and d   b and c   c and d5) Because of (3) and (4), we can create additional equations using cross   products:   a cross b equals c cross d (equation 3 out of 4)   d cross a equals b cross c (equation 4 out of 4) So, if you write out all that, you'll have 4 equations. Note that equation 1 involves the unknown z components of a and c, while equation 2 involves the unknown z components of b and d. These two sets are not coupled. Equations 3 and four add the coupling to give you a set of 4 simultaneous equations that you can solve for the missing z's.Hope that helps![Edited by - grhodes_at_work on April 9, 2010 1:42:39 PM];  I want to clarify my candidate solution a bit. The unknown "z_u" coordinates you are solving for (the image space z coordinates of the edge vectors)...they are components of directional vectors. They are not positions in space. Basically, they just give you the depth component of the edge vectors. The cross product of two of the perpendicular pairs then gives you the image space normal vector, also with a depth component. But since you already know the image space positions of points, you can take the vectors and normal that collectively make up the image space coordinate system basis and combine with the known image space positions to get a transformation matrix to put your projected image in the place you want it to appear.I should also note that my proposed solution...I thought about it quickly. I haven't rigorously analyzed the approach to be certain you will be able to solve the set of equations I proposed. I think it will work, just not 100% certain. But, should be easy to implement.   ;  Oh, another thing...I corrected an error in the first two equations....please take note if you started out before I changed it!   ;  Thanks for the response and idea.  I'll post later if i have any success or not.   ;  Looking forward to hearing an update about your progress, whether you were able to adapt my ideas above or tried a different approach. Let us know how it is going!   ;  I'm sorry for answering this thread without actually having read it. However your question made me think of these pages which was linked from the webpage of a course i took a few months ago.http://www.csc.kth.se/utbildning/kth/kurser/DD2423/bildat10/projection-cipolla.pdfhttp://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/EPSRC_SSAZ/epsrc_ssaz.html   