Alex Rivera | Logout

Why are there 3 conflicting OpenCV camera calibration formulas?

Asked 2010-05-19T03:10:58.587
12

I'm having a problem with OpenCV's various parameterization of coordinates used for camera calibration purposes. The problem is that three different sources of information on image distortion formulae apparently give three non-equivalent description of the parameters and equations involved:

(1) In their book "Learning OpenCV…" Bradski and Kaehler write regarding lens distortion (page 376):

xcorrected = x * ( 1 + k1 * r^2 + k2 * r^4  + k3 * r^6 ) + [ 2 * p1 * x * y + p2 * ( r^2 + 2 * x^2 ) ],

ycorrected = y * ( 1 + k1 * r^2 + k2 * r^4  + k3 * r^6 ) + [ p1 * ( r^2 + 2 * y^2 ) + 2 * p2 * x * y ],

where r = sqrt( x^2 + y^2 ).

Assumably, (x, y) are the coordinates of pixels in the uncorrected captured image corresponding to world-point objects with coordinates (X, Y, Z), camera-frame referenced, for which

xcorrected = fx * ( X / Z ) + cx    and     ycorrected = fy * ( Y / Z ) + cy,

where fx, fy, cx, and cy, are the camera's intrinsic parameters. So, having (x, y) from a captured image, we can obtain the desired coordinates ( xcorrected, ycorrected ) to produced an undistorted image of the captured world scene by applying the above first two correction expressions.

However...

(2) The complication arises as we look at OpenCV 2.0 C Reference entry under the Camera Calibration and 3D Reconstruction section. For ease of comparison we start with all world-point (X, Y, Z) coordinates being expressed with respect to the camera's reference frame, just as in #1. Consequently, the transformation matrix [ R | t ] is of no concern.

In the C reference, it is expressed that:

x' = X / Z,

y' = Y / Z,

x'' = x' * ( 1 + k1 * r'^2 + k2 * r'^4  + k3 * r'^6 ) + [ 2 * p1 * x' * y' + p2 * ( r'^2 + 2 * x'^2 ) ],

y'' = y' *  ( 1 + k1 * r'^2 + k2 * r'^4  + k3 * r'^6 ) + [ p1 * ( r'^2 + 2 * y'^2 )  + 2 * p2 * x' * y' ],
Edit
Report

1 Answer

3

There is no one and only formula for camera calibration, they are all valid. Notice the first one contains constants K1, K2 & K3 for r^2, r^4 & r^6, and the other two only have constants for r^2 and r^4? That is because they are all approximate models. The first one is likely to be more accurate since it has more parameters.

Anytime you see:

r = sqrt( x^2 + y^2 )

it is probably safe to assume x = (the x coordinate pixel) - (the camera center in pixels) since r usually means radius from the center.

What are you trying to do by the way? Estimate the camera parameters, correct for lens distortion, or both?

answered 2010-06-24T01:24:43.107

Your Answer