3

Apologies if this is a dumb question, i'm very new to working in 3D.

I have a number of pinhole cameras with a 3x3 rotation matrix and a translation vector based around the origin (0,0,0).

The system I'm working with can move the origin point and rotate the cameras (though all kept relative to one another), resulting in a new rotation matrix and translation vector for each camera, which I can access.

My question then, is: given a point with a 3D position in the original space, how does one compute the 3D position of the same point in the new space using the new rotation/translation of the same camera (or cameras)?

And while I'm asking questions, is there a more efficient means of doing so?

user807068
  • 33
  • 3
  • Can you boil that problem down and present the essence? – P i Jun 21 '11 at 06:13
  • I suppose the "essence" is: how do you find the new 3D position of a point when the origin changes, given the extrinsic parameters of a pinhole camera before and after the change? – user807068 Jun 21 '11 at 17:24

2 Answers2

0

I would recommend using homogeneous coordinates to keep track of matrices and transformations. I think your question is how do you transform points back and forth between different camera views.

If you represent a camera transformation as a single matrix operation M, then going backwards is just inverse(M). Even better, if your camera matrix is the composition of several steps you can invert the steps. For example if M=rotatex(theta) * scale(sx, sy, sz) * translate(x, y, z), then inverse(M) = translate(-x, -y, -z) * scale(1/sx, 1/sy, 1/sz) * rotatex(-theta). Notice you also have to reverse the order. It's the "socks/shoes" property. You put on your socks, then put on your shoes. To reverse you take off your shoes, then take off your socks.

Once you can go forward and backward from each camera, you can swap points between any camera view easily.

Nathan Whitehead
  • 1,942
  • 2
  • 16
  • 19
  • Thanks for responding! Sadly, no, I realize how to swap between camera views of a static scene. My question is regarding what happens when a new point is selected as the origin, changing the rotation/translation of cameras with regard to the new origin, despite the cameras being stationary in "real space". So, for example, I would have two sets of rotation and translation matrices for each camera: one before the origin change and one after. Is there any way to use these values to determine the position of a point relative to the new origin based on its previous position? – user807068 Jun 22 '11 at 02:00
0

I assume that the position of your points are relative to the origin matrix, which you say can be translated/rotated.

Assuming all this is necessary, the new positions of your points are given by:

pos_newCoord = R^-1 * T^-1 * pos_oldCoord

What you're doing is you're taking your new origin, translating it back to the old origin, and unrotating it. Written another way:

newOrigin = myTranslation(myRotation(oldOrigin))
def newCoordinates(point):
    return inverse(myRotation)(inverse(myTranslation)(point))

You can pre-calculate the inverse operations, especially if you're using 4d matrices.


"how to determine the change in rotation and translation for the origin based around the changes of rotation and translation for the cameras?" –OP

If you are not told this information, you can recover it as follows. We'll be using 4d points and a 4v4 affine transformation matrix ( en.wikipedia.org/wiki/Affine_transformation ).

  • Take the any 4 cameras.
  • Consider the original camera points vs their translated/rotated points.
  • There's probably a nicer linear algebra way to do it, but if you visit the Wikipedia link, we notice there's a 3x3 submatrix A and a 3x1 submatrix b, and thus 12 unknowns. 4 points with 3 equations per point gives you 12 equations. There's a solution because matrices of this form are invertible*. Solve using your favorite system-of-linear-equation solving technique, e.g. Gaussian elimination on a 12x12 matrix.
ninjagecko
  • 88,546
  • 24
  • 137
  • 145
  • Thanks for the input! My next question is then how to determine the change in rotation and translation for the origin based around the changes of rotation and translation for the cameras. – user807068 Jun 22 '11 at 01:52
  • @user807068: If you are not told this information, you can recover it as follows: Take the 4 cameras, and consider their original points vs their translated/rotated points. We'll be using 4d points and a 4v4 affine transformation matrix ( http://en.wikipedia.org/wiki/Affine_transformation ). There's probably a nicer linear algebra way to do it, but you can just notice there's a 3x3 submatrix A and a 3x1 submatrix b, and thus 12 unknowns. 4 points with 3 equations per point gives you 12 equations. There's a solution because matrices of this form are invertible. Solve with Gaussian elimination. – ninjagecko Jun 22 '11 at 07:45