How to recover the 3x4 pinhole camera from 9 parameters

which is the supporting data for a paper titled: Bundle Adjustment in the Large

I want to use the data for triangulation algorithm testing, which requires 3x4 pinhole camera matrices; however the pinhole cameras were all calibrated into 9 parameters:

e.g.

1.5741515942940262e-02 //first three represent the R rotation,
-1.2790936163850642e-02
-4.4008498081980789e-03
-3.4093839577186584e-02// 4~6 are the t' translation vector
-1.0751387104921525e-01
1.1202240291236032e+00
3.9975152639358436e+02 // the 7th is focal length
-3.1770643852803579e-07 // the last two are radial distortion parameters.
5.8820490534594022e-13.


though there is already a reference on how to recover the R from the first three numbers: Rodrigues's vector per the original authors: description here

I still feel it is difficult for me to understand it, especially the how to recover the R from the first three numbers. Anyone has suggestions?

Camera Model

We use a pinhole camera model; the parameters we estimate for each camera area rotation R, a translation t, a focal length f and two radial distortion parameters k1 and k2. The formula for projecting a 3D point X into a camera R,t,f,k1,k2 is:
P  =  R * X + t       (conversion from world to camera coordinates)
p  = -P / P.z         (perspective division)
p' =  f * r(p) * p    (conversion to pixel coordinates)
where P.z is the third (z) coordinate of P. In the last equation, r(p) is a function that computes a scaling factor to undo the radial distortion:
r(p) = 1.0 + k1 * ||p||^2 + k2 * ||p||^4.
This gives a projection in pixels, where the origin of the image is the center of the image, the positive x-axis points right, and the positive y-axis points up (in addition, in the camera coordinate system, the positive z-axis points backwards, so the camera is looking down the negative z-axis, as in OpenGL).


Data Format

Each problem is provided as a bzip2 compressed text file in the following format.

<num_cameras> <num_points> <num_observations>
<camera_index_1> <point_index_1> <x_1> <y_1>
...
<camera_index_num_observations> <point_index_num_observations> <x_num_observations> <y_num_observations>
<camera_1>
...
<camera_num_cameras>
<point_1>
...
<point_num_points>

Where, there camera and point indices start from 0. Each camera is a set of 9 parameters - R,t,f,k1 and k2. The rotation R is specified as a Rodrigues' vector.


To convert from Rodrigues vector to a rotation matrix (and back) please check the MATLAB code here: http://www.cs.ucla.edu/~soatto/vision/courses/268/rodrigues.m

So this gives you the rotation matrix.

You use the translation parameters directly.

Additionally, you might want to form the camera matrix. It would be a good idea to get a fully calibrated K (which involves the camera center). If you can't, just do as follows:

The authors claim to have it as the image center, so will use it as our center. Again in MATLAB notation: K=[f, 0, w/2; 0, f, h/2; 0, 0, 1], where w and h are image width and height respectively. Then you can form P = K*[R | t] which you could directly use for projecting to image coordinates (if you ignore the distortion only). If you need to take into account the distortion, then do the computation as the authors describe.

• The rodrigues.m is dependent on the other three functions which are missing from the original website. Would you please also indicate the location? (1)% -> ~/src/matlab/detensor.m (2)% -> ~/src/matlab/dABdA.m (3)% -> ~/src/matlab/dABdB.m – LCFactorization Dec 25 '13 at 4:43
• Can you please indicate in formula how to convert the three parameters into the unit vector which represents the rotation direction and the $\theta$ of rotation angle? – LCFactorization Dec 25 '13 at 4:46
• For an m-file without dependencies, you could check: daesik80.com/matlabfns/function/Rodrigues.m – Tolga Birdal Dec 25 '13 at 10:40
• Rodrigues' rotation formula is used to rotate a vector represented by an axis and an angle. If you have 3 angles, also called Euler angles, you might consider the following, for a conversion: euclideanspace.com/maths/geometry/rotations/conversions/… I am providing the link, not to duplicate and get author's credit. – Tolga Birdal Dec 25 '13 at 10:48
• thank you. I am not familiar with the conventions used by the professionals. Rodrigues vector` seems to be such a vector: the magnitude is the rotation angle $\theta$ in radian; the normalized Rodrigues vector represents rotation axis' unit direction. Am I right? Is this the convention used by the authors of the data? – LCFactorization Dec 25 '13 at 12:19