Ask Your Question

cv::undistort and values of distortion coefficent

asked 2013-08-30 10:09:47 -0600

nkint gravatar image

updated 2013-08-30 10:43:51 -0600


I'm porting to opencv a little script for lens distortion correction.

This program is doing the undistortion with the Brown normalization, and it uses some parameters that gets out of a (close source) software for camera calibration that has values in the so called photogrammetric representation.

The main difference I have noticed till now is that it express values of focal length and principal points in mm while opencv undistort function takes values in pixel. Ok, I have pixel dimension and I can do this conversion.

But.. Even after this conversion the cv::undistort function still gets me an image that is not correctly undistorted.

I think that there should be some scaling factor that I'm not considering. So I'm asking: what are the values of distortion coefficent units? Are they in radians? Or there is some other conversion that I have to do? Some advice?

EDIT: I report the name of the log and how I'm using it (referring to opencv cv::undistort documentation):

Camera interior orientation: focal length (mm), principal point (mm). Radial distortion parameters: k1, k2, k3 Decentring distortion parameters: p1, p2 Affinity, non-orthogonality parameters: b1, b2

I'm using focal length parameter (scaled in pixel) for fx anf fy, principal point (scaled in pixel as well) as cx, cy. k1, k2, k3, p1, p2 as they are b1, b2: not using those parameters.

edit retag flag offensive close merge delete


Can you post all the values for the variables mentioned above, including image width x height.

Nghia gravatar imageNghia ( 2014-01-16 19:34:40 -0600 )edit

3 answers

Sort by ยป oldest newest most voted

answered 2014-01-16 16:10:47 -0600

jensenb gravatar image

The radial distortion parameters (k1 .. k3 or .. k6 for the ration model) and the tangential (decentering) parameters (p1, p2) are meant to be applied to normalised image coordinates, that is

image description

where u, v are image coordinates and x, y normalized coordinates. It doesn't make much sense to talk about a unit for the parameters of either these two distortion models, since they are just coefficients for approximating (through Taylor expansion) some unknown true lens distortion function. Every calibration implementation I have ever seen has estimated the distortion parameters for normalized image coordinates, as this is ubiquitous in the literature.

Without seeing the incorrect undistorted images, I can only speculate about the cause of the problem, but I think it might be related to

  • Incorrect center of projection (cx, cy). This has a large effect on the undistortion effects, so if you are seeing the undistortion being applied unevenly (some areas too much, others too little), this is likely the cause.
  • Parameter packing. OpenCV currently packs the distortion parameter vector in a slightly odd order [k1, k2, p1, p2, k3, k4, k5 , k6], so make you are translating parameters in the correct order.
edit flag offensive delete link more

answered 2015-06-09 06:14:56 -0600

Giancola gravatar image

I confirm that the correct order of distorsion coefficents is : [k1, k2, p1, p2, k3, k4, k5 , k6] I have an question about principal point, can we compare it with ideal centrl point fixed in the center of the image? Can we evaluate the goodness of calibration doing this comparison? ( if is it nearer is better? )

edit flag offensive delete link more

answered 2014-01-16 11:00:18 -0600

I have the same problem, conversion of radial distortion from Photomodeler to OpenCV, i.e. from millimeters to pixel (or normalized pixel)

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-08-30 10:09:47 -0600

Seen: 5,729 times

Last updated: Jun 09 '15