22
$\begingroup$

To find the intrinsic and extrinsic parameters I calibrated it and the software gave me the extrinsic parameters as a 4 x 4 matrix. This seems to be a 4x4 homogeneous transformation matrix.

The values are as follows

$ \left( \begin{array} 0.211 & -.306 & -.928 & .789 \\ .662 & .742 & -.0947 & .147 \\ .718 & -.595 & .360 & 3.26 \\ 0 & 0 &0 & 1 \\ \end{array} \right) $ I also have the intrinsic parameters of the camera like focal length, principal point, skew, distortion co-efficients etc.

How do I extract the camera position and rotation in world co-ordinates using this matrix?

EDIT:

cam image

On the left I have shown a cam and its viewing a 3d object, and I take a photo of this 3D object from the cam. THe right is what I want. I want to get the world postion/rotation of the cam and the world positon/rotation and actual size of the image in 3d space.

2 Answers 2

20

Assuming your matrix is an extrinsic parameter matrix of the kind described in the Wikipedia article, it is a mapping from world coordinates to camera coordinates. So, to find the position $C$ of the camera, we solve

$\begin{align*}0 &= RC + T\\ C &= -R^T T \approx (-2.604, 2.072, -0.427).\end{align*}$

The orientation of the camera is given simply by $R^T.$ So if the "in" axis is the z-axis, for instance, then the vector pointing in the direction the camera is pointing is

$R^T \left[\begin{array}{c}0\\0\\1\end{array}\right] = (0.718, -0.595, 0.36).$

  • 0
    Thank you very much for your response. What do you mean with "in" axes? I'm using a right handed reference XZY where Z is the Up direction and I'm not able to get the orientation to work correctly by using R_transpose .. am I doing something worng?2018-10-16
4

I am not familiar enough with this domain to know what the conventions are, but I can provide some general context.

A $4 \times 4$ homogeneous camera matrix transforms coordinates from world space to camera space. Apparently, this matrix does not include a perspective projection, so we're effectively talking about an affine transformation. The matrix itself can tell you where the camera is in world space and in what direction it's pointing, but it can't tell you anything else—you need other parameters of the camera for that.

Because we're just talking about a transformation here, we need conventions to tell us about the camera. The conventions that I'm used to are that in camera space, the camera is situated at the origin, and has axes that look like this:

camera axes

In other words, the camera is looking along the positive Z axis, and the Y axis is up. In this system, you can transform the vector $\left[0, 0, 1\right]$ by the transformation's inverse to get the camera's viewing vector in world space, and the point $\left[0, 0, 0\right]$ to get the camera's position in world space.

The general form of this is that the camera's position is $M^{-1} \, \left[\begin{array}{c} 0 \\ 0 \\ 0 \\ 1 \end{array} \right]$ and the camera's viewing vector is $M^{-1} \, \left[\begin{array}{c} 0 \\ 0 \\ 1 \\ 0 \end{array} \right]$, but if you have a matrix that looks like

$\left[\begin{array}{cccc}\phantom{M}&&&\ \\ & R & & T \\ &&& \\ 0 & 0 & 0 & 1 \end{array} \right]$

where $R$ is a $3 \times 3$ matrix and $T$ is a vector, then the camera position is just $-R^T T$ and the camera viewing direction is $R^T \, \left[\begin{array}{c} 0 \\ 0 \\ 1 \end{array} \right]$.

This tells you about as much as you can possibly get from the matrix. Everything else depends on the other properties of the camera.

  • 0
    Why don't you use standard right-handed system? `Y` should be pointing down for standard axis in right-handed system2018-06-03