Add symmetric circles board

This commit is contained in:
Smirnov Egor 2022-06-22 15:04:46 +03:00
parent 734e309b3e
commit 2c2466fb25
5 changed files with 30 additions and 3 deletions

View File

@ -21,7 +21,7 @@ namespace calib
enum InputType { Video, Pictures };
enum InputVideoSource { Camera, File };
enum TemplateType { AcirclesGrid, Chessboard, chAruco, DoubleAcirclesGrid };
enum TemplateType { AcirclesGrid, Chessboard, chAruco, DoubleAcirclesGrid, CirclesGrid };
static const std::string mainWindowName = "Calibration";
static const std::string gridWindowName = "Board locations";

View File

@ -108,6 +108,16 @@ bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame)
return false;
}
bool CalibProcessor::detectAndParseCircles(const cv::Mat &frame)
{
bool isTemplateFound = findCirclesGrid(frame, mBoardSize, mCurrentImagePoints, cv::CALIB_CB_SYMMETRIC_GRID, mBlobDetectorPtr);
if(isTemplateFound) {
mTemplateLocations.insert(mTemplateLocations.begin(), mCurrentImagePoints[0]);
cv::drawChessboardCorners(frame, mBoardSize, cv::Mat(mCurrentImagePoints), isTemplateFound);
}
return isTemplateFound;
}
bool CalibProcessor::detectAndParseACircles(const cv::Mat &frame)
{
bool isTemplateFound = findCirclesGrid(frame, mBoardSize, mCurrentImagePoints, cv::CALIB_CB_ASYMMETRIC_GRID, mBlobDetectorPtr);
@ -160,6 +170,14 @@ void CalibProcessor::saveFrameData()
mCalibData->allCharucoCorners.push_back(mCurrentCharucoCorners);
mCalibData->allCharucoIds.push_back(mCurrentCharucoIds);
break;
case CirclesGrid:
objectPoints.reserve(mBoardSize.height*mBoardSize.width);
for( int i = 0; i < mBoardSize.height; i++ )
for( int j = 0; j < mBoardSize.width; j++ )
objectPoints.push_back(cv::Point3f(j*mSquareSize, i*mSquareSize, 0));
mCalibData->imagePoints.push_back(mCurrentImagePoints);
mCalibData->objectPoints.push_back(objectPoints);
break;
case AcirclesGrid:
objectPoints.reserve(mBoardSize.height*mBoardSize.width);
for( int i = 0; i < mBoardSize.height; i++ )
@ -278,6 +296,7 @@ CalibProcessor::CalibProcessor(cv::Ptr<calibrationData> data, captureParameters
capParams.charucoMarkerSize, mArucoDictionary);
#endif
break;
case CirclesGrid:
case AcirclesGrid:
mBlobDetectorPtr = cv::SimpleBlobDetector::create();
break;
@ -308,6 +327,9 @@ cv::Mat CalibProcessor::processFrame(const cv::Mat &frame)
case chAruco:
isTemplateFound = detectAndParseChAruco(frameCopy);
break;
case CirclesGrid:
isTemplateFound = detectAndParseCircles(frameCopy);
break;
case AcirclesGrid:
isTemplateFound = detectAndParseACircles(frameCopy);
break;

View File

@ -54,6 +54,7 @@ protected:
bool detectAndParseChessboard(const cv::Mat& frame);
bool detectAndParseChAruco(const cv::Mat& frame);
bool detectAndParseCircles(const cv::Mat& frame);
bool detectAndParseACircles(const cv::Mat& frame);
bool detectAndParseDualACircles(const cv::Mat& frame);
void saveFrameData();

View File

@ -30,7 +30,7 @@ const std::string keys =
"{v | | Input from video file }"
"{ci | 0 | Default camera id }"
"{flip | false | Vertical flip of input frames }"
"{t | circles | Template for calibration (circles, chessboard, dualCircles, charuco) }"
"{t | circles | Template for calibration (circles, chessboard, dualCircles, charuco, symcircles) }"
"{sz | 16.3 | Distance between two nearest centers of circles or squares on calibration board}"
"{dst | 295 | Distance between white and black parts of daulCircles template}"
"{w | | Width of template (in corners or circles)}"

View File

@ -107,7 +107,11 @@ bool calib::parametersController::loadFromParser(cv::CommandLineParser &parser)
std::string templateType = parser.get<std::string>("t");
if(templateType.find("circles", 0) == 0) {
if(templateType.find("symcircles", 0) == 0) {
mCapParams.board = CirclesGrid;
mCapParams.boardSize = cv::Size(4, 11);
}
else if(templateType.find("circles", 0) == 0) {
mCapParams.board = AcirclesGrid;
mCapParams.boardSize = cv::Size(4, 11);
}