Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding 3D position of a camera used to take a 2D picture

Given a 3D scene and a 2D image of part of that scene, is it possible to find the position of the camera used to make the image?

like image 857
phpscriptcoder Avatar asked Oct 28 '11 04:10

phpscriptcoder


2 Answers

I'm going to assume from your question that you have four points in the 2-D space whose locations you know in the 3-D space. (If your real problem is identifying those point, I haven't the foggiest idea where to begin.)

Your question is therefore, where can the camera be to have produced this mapping from model to image?

The camera is performing an affine transformation of the form M x + T = y, where x is a vector in 3-space representing the point in the model and y is the 2-space vector representing the point in the image. Given four values for x and y, it's a straightforward matrix-arithmetic problem to solve for M and T (probably best to get MATLAB to help you here.)

Now, how do you translate M and T to position, location, and focal length of the camera? There it gets a little hairy but this page should help you (just remember, you are doing everything backwards).

like image 127
Michael Lorton Avatar answered Nov 08 '22 18:11

Michael Lorton


If you take a random sampling of camera parameters, rendering the scene with each set of parameters, you can take the best matches as a starting point. You can then perform a local optimization of the camera parameters to find those parameters which reproduce the 2D image the closest. It isn't fast, but theoretically you could come up with very good guesses given enough time.

like image 36
Vaughn Cato Avatar answered Nov 08 '22 19:11

Vaughn Cato