diff --git a/apps/interactive-calibration/CMakeLists.txt b/apps/interactive-calibration/CMakeLists.txt index 735c4538ef..41abf7c908 100644 --- a/apps/interactive-calibration/CMakeLists.txt +++ b/apps/interactive-calibration/CMakeLists.txt @@ -1,4 +1,7 @@ -set(OPENCV_INTERACTIVECALIBRATION_DEPS opencv_core opencv_imgproc opencv_features2d opencv_aruco opencv_highgui opencv_calib3d opencv_videoio) +set(OPENCV_INTERACTIVECALIBRATION_DEPS opencv_core opencv_imgproc opencv_features2d opencv_highgui opencv_calib3d opencv_videoio) +if(${BUILD_opencv_aruco}) + list(APPEND OPENCV_INTERACTIVECALIBRATION_DEPS opencv_aruco) +endif() ocv_check_dependencies(${OPENCV_INTERACTIVECALIBRATION_DEPS}) if(NOT OCV_DEPENDENCIES_FOUND) diff --git a/apps/interactive-calibration/frameProcessor.cpp b/apps/interactive-calibration/frameProcessor.cpp index 1e672b0c45..07b32dbe12 100644 --- a/apps/interactive-calibration/frameProcessor.cpp +++ b/apps/interactive-calibration/frameProcessor.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -75,6 +74,7 @@ bool CalibProcessor::detectAndParseChessboard(const cv::Mat &frame) bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame) { +#ifdef HAVE_OPENCV_ARUCO cv::Ptr board = mCharucoBoard.staticCast(); std::vector > corners, rejected; @@ -95,14 +95,16 @@ bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame) } centerX /= currentCharucoCorners.size[0]; centerY /= currentCharucoCorners.size[0]; - //cv::circle(frame, cv::Point2f(centerX, centerY), 10, cv::Scalar(0, 255, 0), 10); + mTemplateLocations.insert(mTemplateLocations.begin(), cv::Point2f(centerX, centerY)); cv::aruco::drawDetectedCornersCharuco(frame, currentCharucoCorners, currentCharucoIds); mCurrentCharucoCorners = currentCharucoCorners; mCurrentCharucoIds = currentCharucoIds; return true; } - +#else + (void)frame; +#endif return false; } @@ -231,6 +233,7 @@ bool CalibProcessor::checkLastFrame() } } else { +#ifdef HAVE_OPENCV_ARUCO cv::Mat r, t, angles; std::vector allObjPoints; allObjPoints.reserve(mCurrentCharucoIds.total()); @@ -248,6 +251,7 @@ bool CalibProcessor::checkLastFrame() mCalibData->allCharucoCorners.pop_back(); mCalibData->allCharucoIds.pop_back(); } +#endif } return isFrameBad; } @@ -266,10 +270,12 @@ CalibProcessor::CalibProcessor(cv::Ptr data, captureParameters switch(mBoardType) { case chAruco: +#ifdef HAVE_OPENCV_ARUCO mArucoDictionary = cv::aruco::getPredefinedDictionary( cv::aruco::PREDEFINED_DICTIONARY_NAME(capParams.charucoDictName)); mCharucoBoard = cv::aruco::CharucoBoard::create(mBoardSize.width, mBoardSize.height, capParams.charucoSquareLenght, capParams.charucoMarkerSize, mArucoDictionary); +#endif break; case AcirclesGrid: mBlobDetectorPtr = cv::SimpleBlobDetector::create(); diff --git a/apps/interactive-calibration/frameProcessor.hpp b/apps/interactive-calibration/frameProcessor.hpp index 4dbb8ab314..222b83143f 100644 --- a/apps/interactive-calibration/frameProcessor.hpp +++ b/apps/interactive-calibration/frameProcessor.hpp @@ -6,8 +6,10 @@ #define FRAME_PROCESSOR_HPP #include -#include #include +#ifdef HAVE_OPENCV_ARUCO +#include +#endif #include "calibCommon.hpp" #include "calibController.hpp" @@ -37,8 +39,10 @@ protected: cv::Mat mCurrentCharucoIds; cv::Ptr mBlobDetectorPtr; +#ifdef HAVE_OPENCV_ARUCO cv::Ptr mArucoDictionary; cv::Ptr mCharucoBoard; +#endif int mNeededFramesNum; unsigned mDelayBetweenCaptures; diff --git a/apps/interactive-calibration/main.cpp b/apps/interactive-calibration/main.cpp index af62d4ea40..10d3690b89 100644 --- a/apps/interactive-calibration/main.cpp +++ b/apps/interactive-calibration/main.cpp @@ -4,10 +4,13 @@ #include #include -#include #include #include +#ifdef HAVE_OPENCV_ARUCO +#include +#endif + #include #include #include @@ -50,31 +53,27 @@ bool calib::showOverlayMessage(const std::string& message) #endif } -static void deleteButton(int state, void* data) +static void deleteButton(int, void* data) { - state++; //to avoid gcc warnings (static_cast*>(data))->get()->deleteLastFrame(); calib::showOverlayMessage("Last frame deleted"); } -static void deleteAllButton(int state, void* data) +static void deleteAllButton(int, void* data) { - state++; (static_cast*>(data))->get()->deleteAllData(); calib::showOverlayMessage("All frames deleted"); } -static void saveCurrentParamsButton(int state, void* data) +static void saveCurrentParamsButton(int, void* data) { - state++; if((static_cast*>(data))->get()->saveCurrentCameraParameters()) calib::showOverlayMessage("Calibration parameters saved"); } #ifdef HAVE_QT -static void switchVisualizationModeButton(int state, void* data) +static void switchVisualizationModeButton(int, void* data) { - state++; ShowProcessor* processor = static_cast(((cv::Ptr*)data)->get()); processor->switchVisualizationMode(); } @@ -103,6 +102,11 @@ int main(int argc, char** argv) captureParameters capParams = paramsController.getCaptureParameters(); internalParameters intParams = paramsController.getInternalParameters(); +#ifndef HAVE_OPENCV_ARUCO + if(capParams.board == chAruco) + CV_Error(cv::Error::StsNotImplemented, "Aruco module is disabled in current build configuration." + " Consider usage of another calibration pattern\n"); +#endif cv::TermCriteria solverTermCrit = cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS, intParams.solverMaxIters, intParams.solverEps); @@ -172,6 +176,7 @@ int main(int argc, char** argv) calibrationFlags, solverTermCrit); } else { +#ifdef HAVE_OPENCV_ARUCO cv::Ptr dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME(capParams.charucoDictName)); cv::Ptr charucoboard = @@ -183,6 +188,7 @@ int main(int argc, char** argv) globalData->cameraMatrix, globalData->distCoeffs, cv::noArray(), cv::noArray(), globalData->stdDeviations, cv::noArray(), globalData->perViewErrors, calibrationFlags, solverTermCrit); +#endif } dataController->updateUndistortMap(); dataController->printParametersToConsole(std::cout);