I have problem with finding ChArUco board corners properly effect below:
https://youtu.be/Qq9FH4kPwwI
My code below:
bool CharucoBoardCalibration::findAndDraw(cv::Mat& frame, cv::Mat& outputFrame, bool showResult) { std::vector<int> ids; std::vector<std::vector<cv::point2f>> corners, rejected; // detect markers cv::aruco::detectMarkers(frame, dictionary, corners, ids, detectorParams, rejected);
// refind strategy to detect more markers
cv::aruco::refineDetectedMarkers(frame, board, corners, ids, rejected);
cv::Mat currentCharucoCorners, currentCharucoIds;
// interpolate charuco corners
if(ids.empty() == true)
{
cv::putText(frame, "No ChArUco found", cv::Point2i(20,40), CV_FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0x00, 0x00, 0xff), 3);
return false;
}
else
{
cv::putText(frame, "ChArUco board was found", cv::Point2i(20,40), CV_FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0x00, 0xff, 0x00), 3);
}
if(ids.size() > 0)
{
cv::aruco::interpolateCornersCharuco(corners, ids, frame, charucoboard, currentCharucoCorners, currentCharucoIds);
}
if(showResult == true )
{
if(ids.size() > 0)
{
cv::aruco::drawDetectedMarkers(frame, corners);
}
if(currentCharucoCorners.total() > 0)
{
cv::aruco::drawDetectedCornersCharuco(frame, currentCharucoCorners, currentCharucoIds);
}
}
outputFrame = frame;
return true;
}