views:

211

answers:

6

Hi,

I'm new here - so please bear with me if I make a faux pas!

My question is, is there a good algorithm for determining the 3d location and orientation of a camera based on where 3 (or more) known 3d points end up on an image as viewed from that camera?

The question comes down, in my calculation to 6 equations, with 6 unknowns, though I'm looking for a general solution, and the equations are complicated and trigonometric.

Any ideas gratefully recieved!

Cheers,

Mike

+2  A: 

In general I think there will not be a unique solution.

You can seperate it into two problems of three unknowns each: position and orientation. First assume that the camera does not introduce unknown distortions (f'rinstance by projecting the sphere onto a flat piece of film). Disregard orientation for a minute and what you are measuring is angular seperation between the objects. From here on I will assume that there are only three points and that you can distinguish them-- they're different colors or something. Measuring the angle between two known points puts you on a 2-dimensional surface in space (I can't plot up graphics easily, but they look sort of like electric field lines). Adding another point will put you on another, intersecting surface; there is lots of degeneracy and it's not obvious that the equations have a clean exact solution.

It's worth noting that every pair you look at imposes volume constraint, so it might be useful to look at the most obtuse angles first and put some bounds on where the camera can be.

If you can determine position, then orientation is easy, and requires only two (non-eclipsing) points.

Beta
I'm not sure... I think there should be a (reasonably - ie perhaps 2 possibles) unique solution - except perhaps where all the points lie in a plane passing through the camera... which is an instance I can avoid by choosing my points well!I had a go at your idea of just checking the angles (using a dot product), but that left me with 3-d quartic equations! I think perhaps I'm missing something - but can't put my finger on what!
MikeAsh
A: 

With a calibrated camera - yes.
All you need is the focal length (maps pixels into angles) the center axis of the camera (puts a ray into your scene) and then projecting a point on that ray is simple.

Take a look at OpenCV, it does this as par tof the camera calibration for stereo

alt text

Martin Beckett
How can he start with the center axis of the camera, if what he's trying to find is the camera's location and orientation?
Beta
You start with the POSIT algorithm, it should be obvious that for 3 (not co-linear) points a pin-hole camera model there is onyl one place the camera can be.
Martin Beckett
I haven't found a concise statement of POSIT, but I can sketch some counterexamples. I'm sorry, but this starting point doesn't work either.
Beta
I had a look at OpenCV, and I'm a little out of my depth with it! I'm not really a programmer; I dabble in POV-ray, which is as close as I get - and actually where this problem comes from!
MikeAsh
If you are familair with the maths of 3d (essential matrix, projection etC) then the explanation in the book is pretty good. Even if you don't use openCV.
Martin Beckett
A: 

Is this a virtual camera or a real camera? You will also need to look as f/stop and focal length and possibly even the shape of the optics. It really depends on how accurate you need to be for the position and how far apart the objects that were photographed are from each other. If you are using a 200mm zoom with a focus of only a few feet your field of view may only be a few inches across. Yet if you use a 4.5mm full circle fisheye you and have direct circular projection you may have 180 degrees of view.

Matthew Whited
A: 

If you think about it... it's actually a somewhat simple idea... here's my train of thought:

  1. Find the plane that the 3 points sit on. This plane will be parallel to your projection plane.
    1. Assuming that you have point A, B and C. Find the cross product of the vector going from A to B and A to C
    2. Normalize it. That's your plane's normal.
    3. Solve for the barycentric equation by plugging in values for Ax + By + Cz + D = 0 where A is the x of the normal, B is y of the normal, C is the z of the normal and you solve for D. Once you have D, you have the plane's representation.
  2. Find a bounding rectangle around all three points on that plane, this will be your rendering geometry, the end of your frustum (rendering volume).
  3. Find the center point of that bounding rectangle we just found. This is your initial center of projection.
  4. Move that center point away from the bounding rectangle by adding (or subtracting) the normal from the point. Keep moving until you have reached the desired field of view.
jghost
I must be missing something. In step 1, how do you know that the three points in space are in a plane parallel to the projection plane?
Beta
Well, you don't. Because the author didn't mention requirements, this is the easiest approach. I'm sure you can try to define the bounding box of the points and try to construct a frustum that optimally encloses the bounding box... but it's much easier to assume the plane is parallel to the projection plane.
jghost
A: 

Hi MikeAsh and everybody,

I would like make the same calculations. Do you find an algorithm?

Thank's

Mathieu
A: 

With more than three points, it is certainly possible.

This is the way star trackers work for controlling spacecraft attitude.

mouviciel