'Error while trying to make Camera Calibration using Charuco Board (OpenCV, C++)

I'm trying to find distortion coeffitients using Charuco Board from the Aruco OpenCV library. I'm using Qt and OpenCV libraries compiled for Qt.

First I've needed to do is to create the Charuco Board. I've done it using this:

    using namespace std;
    using namespace cv;
    using namespace cv::aruco;

    ...

    Ptr<Dictionary> dictionary = getPredefinedDictionary(DICT_6X6_250);
    Ptr<CharucoBoard> board = CharucoBoard::create(5, 7, 0.04f, 0.02f, dictionary);
    Ptr<DetectorParameters> params = DetectorParameters::create();
    params->cornerRefinementMethod = CORNER_REFINE_NONE;

After that I have found Markers and Charuco Corners with its IDs on photos using detectMarkers(...) and interpolateCornersCharuco(...) functions. I had 28 photos with the board or its parts. Operation result looks like this (from 5 to 24 allocated corners per each image):

Allocated Charuco Corners

After that I tried to find Camera Matrix and Distortion Coeffitients using this:

    Mat cameraMatrix, distCoeffs;
    vector<Mat> rVectors, tVectors;
    double repError = calibrateCameraCharuco(allCharucoCorners, allCharucoIds, board, imgSize,
                                             cameraMatrix, distCoeffs, rVectors, tVectors);

allCharucoCorners and allCharucoIds are vectors of vectors with equal size, board configured like shown above, imgSize got using function cv::Size(loadedImg.cols, loadedImg.rows).

The program always tries to execute this function, but can not do it. Every time I try I have the project crash without any critical messages.

So maybe someone have an idea about what can be wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source