Ask Your Question
0

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

asked 2019-10-23 22:00:06 -0600

fabianc20 gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2019-10-25 22:11:19 -0600

fabianc20 gravatar image

Learned Lessons:

1.Dataset: Chessborad images, which were the ones I wanted to use, must be fully flat collected. I was using chessboard projected on an object. That is to be done afterwards, once calibration has been acomplished. So I changed the images for 'just' chessboard pattern on its own, with slightly degrees up&down, rigth&left. About 10.

  1. Settings.xml. The settings file needs consistency as well, I was using #corners by counting the number of blocks -squares- over the sides. Wrong! so it is actually the inside corners. So one number less than the squares. There are two blind white outside squares that do not allow to shape 4 corners. So instead of 10, 12 I had it was 9,11.

After that, I got the calibration output I was looking for.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-10-23 22:00:06 -0600

Seen: 259 times

Last updated: Oct 25 '19