简体   繁体   English

尝试使用 Charuco Board (OpenCV, C++) 进行相机校准时出错

[英]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.我正在尝试使用 Aruco OpenCV 库中的 Charuco Board 查找失真系数。 I'm using Qt and OpenCV libraries compiled for Qt.我正在使用为 Qt 编译的 Qt 和 OpenCV 库。

First I've needed to do is to create the Charuco Board.首先我需要做的是创建 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.之后,我使用detectMarkers(...)interpolateCornersCharuco(...)函数在照片上找到了带有 ID 的 Markers 和 Charuco Corners。 I had 28 photos with the board or its parts.我有 28 张与电路板或其部件的照片。 Operation result looks like this (from 5 to 24 allocated corners per each image):操作结果如下所示(每张图像分配 5 到 24 个角):

Allocated Charuco Corners分配的 Charuco 角球

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) . allCharucoCornersallCharucoIds是大小相等的向量, board的配置如上所示, imgSize使用 function cv::Size(loadedImg.cols, loadedImg.rows)

The program always tries to execute this function, but can not do it.程序总是试图执行这个function,但是做不到。 Every time I try I have the project crash without any critical messages.每次我尝试时,我都会在没有任何关键消息的情况下导致项目崩溃。

So maybe someone have an idea about what can be wrong?所以也许有人知道什么可能是错的?

The problem was in OpenCV library.问题出在 OpenCV 库中。 Maybe it was badly compiled, or the problem is in the library itself.也许它编译不好,或者问题出在库本身。 I have used OpenCV version 4.5.3 before.我之前用过 OpenCV 版本 4.5.3。 Then I compiled 4.5.4 version, and the program started to work well.然后我编译了4.5.4版本,程序开始运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM