diff --git a/CMakeLists.txt b/CMakeLists.txt index 891b5a9..e0aeb8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,8 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic") endif() +set (CMAKE_CXX_STANDARD 11) + if(BUILD_DUtils) set(HDRS include/DUtils/ include/DUtils/BinaryFile.h include/DUtils/DUtils.h include/DUtils/FileModes.h include/DUtils/Math.hpp diff --git a/src/DUtilsCV/Drawing.cpp b/src/DUtilsCV/Drawing.cpp index 1b84c1b..c4b8e28 100644 --- a/src/DUtilsCV/Drawing.cpp +++ b/src/DUtilsCV/Drawing.cpp @@ -9,9 +9,10 @@ */ #include -#include -#include -#include +#include +#include +#include +#include #include "Drawing.h" using namespace std; @@ -23,11 +24,11 @@ void Drawing::drawKeyPoints(cv::Mat &image, const std::vector &keypoints, bool colorOctave, bool useCartesianAngle) { - CvScalar colors[4] = { - cvScalar(0, 0, 255), - cvScalar(0, 255, 0), - cvScalar(255, 0, 0), - cvScalar(255, 255, 255) + cv::Scalar colors[4] = { + cv::Scalar(0, 0, 255), + cv::Scalar(0, 255, 0), + cv::Scalar(255, 0, 0), + cv::Scalar(255, 255, 255) }; const double PI = 3.14159265; @@ -39,7 +40,7 @@ void Drawing::drawKeyPoints(cv::Mat &image, float s = it->size / 2.f; //if(s < 3.f) s = 3.f; - const CvScalar *color; + const cv::Scalar *color; if(!colorOctave || it->octave < 1 || it->octave > 3) color = &colors[3]; else @@ -48,7 +49,7 @@ void Drawing::drawKeyPoints(cv::Mat &image, int r1 = (int)(it->pt.y + 0.5); int c1 = (int)(it->pt.x + 0.5); - cv::circle(image, cvPoint(c1, r1), (int)s, *color, 1); + cv::circle(image, cv::Point(c1, r1), (int)s, *color, 1); if(it->angle >= 0) { @@ -62,7 +63,7 @@ void Drawing::drawKeyPoints(cv::Mat &image, else r2 = (int)(s * sin(o) + it->pt.y + 0.5); - cv::line(image, cvPoint(c1, r1), cvPoint(c2, r2), *color); + cv::line(image, cv::Point(c1, r1), cv::Point(c2, r2), *color); } } } @@ -102,12 +103,12 @@ void Drawing::drawCorrespondences(cv::Mat &image, const cv::Mat &img1, cv::Mat aux1, aux2; if(img1.channels() > 1) - cv::cvtColor(img1, aux1, CV_RGB2GRAY); + cv::cvtColor(img1, aux1, cv::COLOR_RGB2GRAY); else aux1 = img1.clone(); if(img2.channels() > 1) - cv::cvtColor(img2, aux2, CV_RGB2GRAY); + cv::cvtColor(img2, aux2, cv::COLOR_RGB2GRAY); else aux2 = img2.clone(); @@ -151,12 +152,12 @@ void Drawing::drawCorrespondences(cv::Mat &image, const cv::Mat &img1, py += img1.rows; - CvScalar color = cvScalar( + cv::Scalar color = cv::Scalar( int(((double)rand()/((double)RAND_MAX + 1.0)) * 256.0), int(((double)rand()/((double)RAND_MAX + 1.0)) * 256.0), int(((double)rand()/((double)RAND_MAX + 1.0)) * 256.0)); - cv::line(image, cvPoint(mx, my), cvPoint(px, py), color, 1); + cv::line(image, cv::Point(mx, my), cv::Point(px, py), color, 1); } } @@ -206,19 +207,19 @@ void Drawing::drawReferenceSystem(cv::Mat &image, const cv::Mat &cRo, cv::projectPoints(cv::Mat(oP), cRo, cto, A, k, points2d); // draw axis - CvScalar bluez, greeny, redx; + cv::Scalar bluez, greeny, redx; if(image.channels() == 3 ) { - bluez = cvScalar(255,0,0); - greeny = cvScalar(0,255,0); - redx = cvScalar(0,0,255); + bluez = cv::Scalar(255,0,0); + greeny = cv::Scalar(0,255,0); + redx = cv::Scalar(0,0,255); } else { - bluez = cvScalar(18,18,18); - greeny = cvScalar(182,182,182); - redx = cvScalar(120,120,120); + bluez = cv::Scalar(18,18,18); + greeny = cv::Scalar(182,182,182); + redx = cv::Scalar(120,120,120); } cv::line(image, points2d[0], points2d[1], redx, 2); diff --git a/src/DUtilsCV/GUI.cpp b/src/DUtilsCV/GUI.cpp index f22a6c5..321233c 100644 --- a/src/DUtilsCV/GUI.cpp +++ b/src/DUtilsCV/GUI.cpp @@ -10,9 +10,12 @@ #include #include -#include -#include -#include + +#include +#include +#include +#include + #include #include #include @@ -39,7 +42,7 @@ int GUI::showImage(const cv::Mat &image, bool autosize, name = ssname.str(); int flags = 0; - if(autosize) flags |= CV_WINDOW_AUTOSIZE; + if(autosize) flags |= cv::WINDOW_AUTOSIZE; cv::namedWindow( name.c_str(), flags ); @@ -81,7 +84,7 @@ int GUI::showImageInfo(const cv::Mat &image, bool autosize, tWinHandler *hwnd = (_hwnd ? _hwnd : &haux); if(image.type() == CV_8U) - cv::cvtColor(image, image_rgb, CV_GRAY2RGB); + cv::cvtColor(image, image_rgb, cv::COLOR_GRAY2RGB); else image_rgb = image; @@ -237,7 +240,7 @@ void GUI::MouseHandler::attach(const tWinHandler &hwnd, void GUI::MouseHandler::attachToClicks(const tWinHandler &hwnd) { m_valid_events.resize(1); - m_valid_events[0] = CV_EVENT_LBUTTONUP; + m_valid_events[0] = cv::EVENT_LBUTTONUP; m_attached = true; cv::setMouseCallback(hwnd, GUI::MouseHandler::callbackHandlerFunction, this); } @@ -247,7 +250,7 @@ void GUI::MouseHandler::attachToClicks(const tWinHandler &hwnd) void GUI::MouseHandler::attachToMotions(const tWinHandler &hwnd) { m_valid_events.resize(1); - m_valid_events[0] = CV_EVENT_MOUSEMOVE; + m_valid_events[0] = cv::EVENT_MOUSEMOVE; m_attached = true; cv::setMouseCallback(hwnd, GUI::MouseHandler::callbackHandlerFunction, this); } @@ -275,16 +278,16 @@ void GUI::MouseHandler::listenToAll() //@note RACE CONDITION! m_valid_events.resize(10); - m_valid_events[0] = CV_EVENT_LBUTTONDOWN; - m_valid_events[1] = CV_EVENT_LBUTTONUP; - m_valid_events[2] = CV_EVENT_LBUTTONDBLCLK; - m_valid_events[3] = CV_EVENT_RBUTTONDOWN; - m_valid_events[4] = CV_EVENT_RBUTTONUP; - m_valid_events[5] = CV_EVENT_RBUTTONDBLCLK; - m_valid_events[6] = CV_EVENT_MBUTTONDOWN; - m_valid_events[7] = CV_EVENT_MBUTTONUP; - m_valid_events[8] = CV_EVENT_MBUTTONDBLCLK; - m_valid_events[9] = CV_EVENT_MOUSEMOVE; + m_valid_events[0] = cv::EVENT_LBUTTONDOWN; + m_valid_events[1] = cv::EVENT_LBUTTONUP; + m_valid_events[2] = cv::EVENT_LBUTTONDBLCLK; + m_valid_events[3] = cv::EVENT_RBUTTONDOWN; + m_valid_events[4] = cv::EVENT_RBUTTONUP; + m_valid_events[5] = cv::EVENT_RBUTTONDBLCLK; + m_valid_events[6] = cv::EVENT_MBUTTONDOWN; + m_valid_events[7] = cv::EVENT_MBUTTONUP; + m_valid_events[8] = cv::EVENT_MBUTTONDBLCLK; + m_valid_events[9] = cv::EVENT_MOUSEMOVE; std::sort(m_valid_events.begin(), m_valid_events.end()); } diff --git a/src/DVision/BRIEF.cpp b/src/DVision/BRIEF.cpp index 8c3bb31..5c65552 100644 --- a/src/DVision/BRIEF.cpp +++ b/src/DVision/BRIEF.cpp @@ -52,7 +52,7 @@ void BRIEF::compute(const cv::Mat &image, cv::Mat aux; if(image.depth() == 3) { - cv::cvtColor(image, aux, CV_RGB2GRAY); + cv::cvtColor(image, aux, cv::COLOR_RGB2GRAY); } else { diff --git a/src/DVision/FSolver.cpp b/src/DVision/FSolver.cpp index 2e2c1a5..ee3a4b5 100644 --- a/src/DVision/FSolver.cpp +++ b/src/DVision/FSolver.cpp @@ -146,7 +146,7 @@ cv::Mat FSolver::findFundamentalMat(const cv::Mat &P1, const cv::Mat &P2, cv::Mat sq_ab, norms; cv::multiply(l1.rowRange(0,2), l1.rowRange(0,2), sq_ab); - cv::reduce(sq_ab, norms, 0, CV_REDUCE_SUM); // 0 = single row + cv::reduce(sq_ab, norms, 0, cv::REDUCE_SUM); // 0 = single row cv::sqrt(norms, norms); // norms is Nx2 cv::Mat thresholds = norms * reprojection_error; // Nx1 @@ -157,7 +157,7 @@ cv::Mat FSolver::findFundamentalMat(const cv::Mat &P1, const cv::Mat &P2, // d(x, l) = dot(x*, l*), * means normalized cv::Mat prod, dot; cv::multiply(l1, Q1, prod); // l1 against Q1 (homogeneous in image coords) - cv::reduce(prod, dot, 0, CV_REDUCE_SUM); // dot is Nx1 + cv::reduce(prod, dot, 0, cv::REDUCE_SUM); // dot is Nx1 // error w/o sign dot = abs(dot); diff --git a/src/DVision/HSolver.cpp b/src/DVision/HSolver.cpp index 2360272..0659df9 100644 --- a/src/DVision/HSolver.cpp +++ b/src/DVision/HSolver.cpp @@ -141,7 +141,7 @@ cv::Mat HSolver::findHomography(const cv::Mat &P1, const cv::Mat &P2, cv::multiply(ab, ab, sq_ab); cv::Mat error; - cv::reduce(sq_ab, error, 0, CV_REDUCE_SUM); // 0 = single row + cv::reduce(sq_ab, error, 0, cv::REDUCE_SUM); // 0 = single row // squared error is positive // get inliers