cv::calibrateCamera fails to start optimization at all with some input images (Bug #592)


Added by Stefan Hahn over 14 years ago. Updated almost 14 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:calibration, 3d
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The problem occurs in cvLevMarqu.updateALT at the line containing change = cvNorm(param, prevParam, CV_RELATIVE_L2)) < criteria.epsilon

For some reason (I could not find out in 8hrs debugging), param and prevParam are sometimes identical, causing the iteration to stop prematurely. In one case with 21 chessboard input images (enclosed), it even stopped without any iteration at all. Removing an arbitrary one of the images let the iteration start. However, testing a lot of calibration sequences showed that every now and then iterations stop prematurely because of param prevparam.

I made a log of the input parameters to the attached file, however did not test, whether it would be possible to reproduce the case by reading them and calling calibrateCamera in a small test case. Flag settings are not recorded in the file. They are CV_CALIB_FIX_ASPECT_RATIO + CV_CALIB_FIX_K3 + CV_CALIB_ZERO_TANGENT_DIST.

I have made a workaround by adding &&(change != 0) to the expression in a local copy of cvcalibration.exe. But since I do not understand how the paramprevparam condition occurs this may not cure the underlying problem.


calib_debug.yml - Point lists for imagePoints and objectPoints in the failing call to cv::calibrateCamera (111 kB) Stefan Hahn, 2010-10-03 08:10 am

cvcalibration.cpp - Added assertion in line 250 - traps when error occurs (111.8 kB) lgpilot -, 2010-10-15 11:41 pm

calib_debug.2.yml - Another set (set no 2) of data. Error occurs after 10 iterations (111.2 kB) Stefan Hahn, 2010-10-15 11:46 pm

snippet.cpp - function calling cvcalibrate (1.5 kB) Stefan Hahn, 2010-10-15 11:58 pm


Associated revisions

Revision 6569a585
Added by Andrey Kamaev about 12 years ago

Merge pull request #592 from vpisarev:c2cpp_calib3d_ptsetreg

History

Updated by Victor Eruhimov over 14 years ago

Hi, could you please provide the source code that reproduces the problem? Thanks, Victor

Updated by Vadim Pisarevsky over 14 years ago

what compiler and what OS are you using? I played with both of your datasets on my machine (MacOSX 10.6, Xcode 3.2.4, GCC 4.2, 64-bit code) and with or without the extra check for "change != 0" I got absolutely the same calibration results. Some compilers are known to produce incorrect code for certain OpenCV functions, and since camera calibration is rounding-error-sensitive algorithm, you might get bad behaviour because of the compiler.

Updated by Vadim Pisarevsky over 14 years ago

  • Status deleted (Open)

Updated by Vadim Pisarevsky almost 14 years ago

  • Status set to Done
  • (deleted custom field) set to obsolete

Also available in: Atom PDF