I am trying to understand how camera matching (or match moving) works. I need to build a program that can move the camera in a way to match a 3D object to its projection on an image. For eg. if I had an image of a cube at some angle, the virtual camera must be moved in such a way that the points/vertices of the 3D cube match up with those in the image.
The inputs would be the image and the points on the image that correspond to each vertex of the the object (cube in the above example).
What is the approach I must take? Is there any algorithm that can help?
This is what I have figured out so far.
So this equation gives the relation between the world coordinates and the image coordinates of a point.
This can be expressed as Xc = R * Xs + T where R represents the rotation of the camera and T represents the translation.
Assuming the user points out which points belong where on the image, I need to compute the R and T matrices now.
I came across the Tsai Calibration Algorithm Which does solve this algorithm at some point. But as you can guess by the name, the algorithm is not designed for camera matching. Also, I don't have a very strong background in math so I need to figure out how to solve this equation. To make things harder the transition from world coordinates to image coordinates must also be figured out.
I need help with somehow modifying this algorithm for camera matching and in solving the mentioned equation.
Please mention any other methods you know of. I do not need to stick to this particular method.
EDIT 2: For anyone who needs more information on camera matching: http://en.wikipedia.org/wiki/Match_moving
But basically the idea is to try and find the location and orientation of the camera from which the actual image must have been taken. Let say I have an image of a Rubik's cube which shows the red and green sides. I also have a 3d model of the Rubik's cube. Now I need to find the location and orientation of the camera such that if I take a picture of the 3d model now then it would look exactly like the image with the red and green sides visible.