diff --git a/apps/interactive-calibration/calibCommon.hpp b/apps/interactive-calibration/calibCommon.hpp index f3fffa1729..81f4355f8e 100644 --- a/apps/interactive-calibration/calibCommon.hpp +++ b/apps/interactive-calibration/calibCommon.hpp @@ -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"; diff --git a/apps/interactive-calibration/frameProcessor.cpp b/apps/interactive-calibration/frameProcessor.cpp index aa164f2a43..217f03c8d1 100644 --- a/apps/interactive-calibration/frameProcessor.cpp +++ b/apps/interactive-calibration/frameProcessor.cpp @@ -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++ ) @@ -288,6 +306,7 @@ CalibProcessor::CalibProcessor(cv::Ptr data, captureParameters capParams.charucoMarkerSize, mArucoDictionary); #endif break; + case CirclesGrid: case AcirclesGrid: mBlobDetectorPtr = cv::SimpleBlobDetector::create(); break; @@ -318,6 +337,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; diff --git a/apps/interactive-calibration/frameProcessor.hpp b/apps/interactive-calibration/frameProcessor.hpp index e048f84320..bae79f930f 100644 --- a/apps/interactive-calibration/frameProcessor.hpp +++ b/apps/interactive-calibration/frameProcessor.hpp @@ -55,6 +55,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(); diff --git a/apps/interactive-calibration/main.cpp b/apps/interactive-calibration/main.cpp index c2a6aa7298..03cf4ca41c 100644 --- a/apps/interactive-calibration/main.cpp +++ b/apps/interactive-calibration/main.cpp @@ -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)}" diff --git a/apps/interactive-calibration/parametersController.cpp b/apps/interactive-calibration/parametersController.cpp index 09f8d337c2..2c9466f430 100644 --- a/apps/interactive-calibration/parametersController.cpp +++ b/apps/interactive-calibration/parametersController.cpp @@ -108,7 +108,11 @@ bool calib::parametersController::loadFromParser(cv::CommandLineParser &parser) std::string templateType = parser.get("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); }