1

I'm trying to understand the logic behind the OpenCV's cv::undisortPoints()' iterative approximation algorithm.

The implementation is available at: https://github.com/Itseez/opencv/blob/master/modules/imgproc/src/undistort.cpp (lines 361-368).

The way I see it:

  • using last best guessed pixel position (x, y), try to find better guess by applying inverse of the 'distortion at current best guess', and adjust the pixel position in regard to the initial distorted position (x0, y0)
  • use initial distorted position (x0, y0) as a first 'best guess'

But the above doesn't really tell why this can be done...

One of the users posted (here: Understanding of openCV undistortion) that this is a kind of "non-linear solving algorithm (e.g. Newton's method, Levenberg-Marquardt algorithm, etc)". And from what I've seen there are at least a few possible solutions to this kind of undistorting problem.


Questions:

  • What iterative algorithm exactly is implemented in cv::undistortPoints()?
    • Is there any white paper showing (and [what's more important] explaining 'like I'm five') the idea behind it?
  • How do we know that this algorithm will converge (at least to the local minimum)?
  • Why do we do the correction in regard to the initial position (x0, y0)?
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
sthlm58
  • 1,142
  • 1
  • 9
  • 28

1 Answers1

1

It uses the false position ("regula falsi") method. I have not seen a proof that the sequence converges for this particular equation, regardless of the choice of distortion parameters (or even for every choice of "physically plausible" parameters). It'd be very easy to write one for a few special cases, e.g. physical pure 2nd-order barrel distortion.

In practice it seems to work well. If you feel uncomfortable with it, you can always replace with the equation solver of your choice. For pure radial distortion of any order (i.e. with a single unknown), you can use any polynomial equation solver, e.g. good old SLATEC's rpqr79.

Francesco Callari
  • 11,300
  • 2
  • 25
  • 40