Ask Your Question
0

Detecting ChAruco board using example code, strange result.

asked 2020-03-20 05:07:55 -0600

antithing gravatar image

I am using the following code, pulled straight from the tutorials:

void detectCharucoBoardWithoutCalibration(cv::Mat image)
{

    cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_1000);
    cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(7, 5, 0.04f, 0.02f, dictionary);
    cv::Ptr<cv::aruco::DetectorParameters> params = cv::aruco::DetectorParameters::create();
    params->cornerRefinementMethod = cv::aruco::CORNER_REFINE_NONE;
        cv::Mat  imageCopy;
        image.copyTo(imageCopy);
        std::vector<int> markerIds;
        std::vector<std::vector<cv::Point2f> > markerCorners;
        cv::aruco::detectMarkers(image, board->dictionary, markerCorners, markerIds, params);
        //or
        //cv::aruco::detectMarkers(image, dictionary, markerCorners, markerIds, params);
        // if at least one marker detected
        if (markerIds.size() > 0) {
            cv::aruco::drawDetectedMarkers(imageCopy, markerCorners, markerIds);
            std::vector<cv::Point2f> charucoCorners;
            std::vector<int> charucoIds;
            cv::aruco::interpolateCornersCharuco(markerCorners, markerIds, image, board, charucoCorners, charucoIds);
            // if at least one charuco corner detected
            if (charucoIds.size() > 0)
                cv::aruco::drawDetectedCornersCharuco(imageCopy, charucoCorners, charucoIds, cv::Scalar(255, 0, 0));
        }
        cv::imshow("out", imageCopy);
        cv::imwrite("data/markers.jpg", imageCopy);
        cv::waitKey(1);

}

instead of the expected corners, I get this result:

image description

What is going wrong here? Why are my corners not aligned?

I have tried other images, and i see the same thing.

Thank you!

edit retag flag offensive close merge delete

Comments

It is difficult to offer ideas without knowing exactly what you expect to happen. When mentioning a tutorial, a link to it would also be helpful.

mvuori gravatar imagemvuori ( 2020-03-20 05:24:27 -0600 )edit

Hi, thanks for your reply. As in the image above, the corner points are misaligned. However, I have just figured this out, and will post an answer now.

antithing gravatar imageantithing ( 2020-03-20 05:52:14 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2020-03-20 05:53:37 -0600

antithing gravatar image

updated 2020-03-20 06:36:23 -0600

supra56 gravatar image

Ah, as usual, user error.

I was passing the number of squares in the format that findChessboard needs, using the inner corners.

cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(7, 5, 0.04f, 0.02f, dictionary);

or indeed any chAruco board, needs the actual number of squares, in this case, 8 x 6.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-03-20 05:07:55 -0600

Seen: 829 times

Last updated: Mar 20 '20