Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

camera_calibration.cpp fails when pasing a file list (InputType = IMAGE_LIST)

Hi dear Opencv'ers

I am triying to calibrate my camera (B-FLIR GigE-13E4C).

Opencv 4.1.1 VS-2019 ver 16.3.5 Windows 10 Pro.

C:\opencv\sources\samples\cpp\tutorial_code\calib3d\camera_calibration.cpp

I have prepared the input -settings- file and a set of chess_board images (xml file), so that I get calibration results with the appropiate InputType=IMAGE_LIST.

Images are read and shown but the conditions to actually run the calibration are never reached. Meaning that the function runCalibrationAndSave(...) is not invoked...

This is the section of code. I include my own cout debug lines, which helped me to realize that I actually never get the calibration, but instead the break; sentence. Which breaks the for loop. Calibration never runs.

CODE:

//! [get_input]
for (;;)
{
    Mat view;
    bool blinkOutput = false;

    view = s.nextImage();

    //-----  If no more image, or got enough, then stop calibration and show result -------------
    if (mode == CAPTURING && imagePoints.size() >= (size_t)s.nrFrames)
    {
        cout << "Line before calling runCalibrationAndSave\n";
        getchar();

        if (runCalibrationAndSave(s, imageSize, cameraMatrix, distCoeffs, imagePoints, grid_width,
            release_object))
            mode = CALIBRATED;
        else
            mode = DETECTION;
    }
    if (view.empty())          // If there are no more images stop the loop
    {
        // if calibration threshold was not reached yet, calibrate now
        if (mode != CALIBRATED && !imagePoints.empty()) {
            cout << "Line before calling runCalibrationAndSave when view.empty \n";
            getchar();
            runCalibrationAndSave(s, imageSize, cameraMatrix, distCoeffs, imagePoints, grid_width,
                release_object);
        }
        break;
    }
    //! [get_input]

I have tried both fisheye 0 and 1 values. Changed the number of images -currently 8. And have followed most of the default settings to reduce the hazards of too many changes.

Am I getting any error mesagges? No, I am just not getting the desire xml uotput_file with the calibration parameters.

I would appriciatte your feedback.