diff --git a/.gitignore b/.gitignore index 611b5adb2c..c58145d030 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ build/ *~ lib/ +.vscode +.clang-format diff --git a/CMakeLists.txt b/CMakeLists.txt index 08a8af468e..465e9ff565 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,42 +7,45 @@ ENDIF() MESSAGE("Build type: " ${CMAKE_BUILD_TYPE}) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native") -# Check C++11 or C++0x support +# Check c++14 or C++0x support include(CheckCXXCompilerFlag) -CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) -if(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - add_definitions(-DCOMPILEDWITHC11) - message(STATUS "Using flag -std=c++11.") +if(COMPILER_SUPPORTS_CXX14) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + add_definitions(-DCOMPILEDWITHC14) + message(STATUS "Using flag -std=c++14.") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") add_definitions(-DCOMPILEDWITHC0X) message(STATUS "Using flag -std=c++0x.") else() - message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no c++14 support. Please use a different C++ compiler.") endif() LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules) -find_package(OpenCV 3.0 QUIET) +find_package(OpenCV 4.2 QUIET) if(NOT OpenCV_FOUND) - find_package(OpenCV 2.4.3 QUIET) + find_package(OpenCV 3.4.7 QUIET) if(NOT OpenCV_FOUND) - message(FATAL_ERROR "OpenCV > 2.4.3 not found.") + message(FATAL_ERROR "OpenCV > 3.4.7 not found.") endif() endif() +message(STATUS "OpenCV library status:") +message(STATUS " version: ${OpenCV_VERSION}") +message(STATUS " libraries: ${OpenCV_LIBS}") +message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}") -find_package(Eigen3 3.1.0 REQUIRED) +find_package(Eigen3 3.1.0 REQUIRED NO_MODULE) find_package(Pangolin REQUIRED) include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include -${EIGEN3_INCLUDE_DIR} ${Pangolin_INCLUDE_DIRS} ) diff --git a/Examples/Monocular/mono_euroc.cc b/Examples/Monocular/mono_euroc.cc index 4bcb90f170..1b17783f56 100644 --- a/Examples/Monocular/mono_euroc.cc +++ b/Examples/Monocular/mono_euroc.cc @@ -70,7 +70,7 @@ int main(int argc, char **argv) for(int ni=0; ni 2.4.3 not found.") + message(FATAL_ERROR "OpenCV > 3.4.7 not found.") endif() endif() diff --git a/Examples/Stereo/stereo_euroc.cc b/Examples/Stereo/stereo_euroc.cc index 6bc09c50be..67b574cdd5 100644 --- a/Examples/Stereo/stereo_euroc.cc +++ b/Examples/Stereo/stereo_euroc.cc @@ -116,8 +116,8 @@ int main(int argc, char **argv) for(int ni=0; ni 2.4.3 not found.") + message(FATAL_ERROR "OpenCV > 3.4.7 not found.") endif() endif() diff --git a/Thirdparty/g2o/g2o/core/sparse_block_matrix.hpp b/Thirdparty/g2o/g2o/core/sparse_block_matrix.hpp index 8dfa99c1b7..247e8d8668 100644 --- a/Thirdparty/g2o/g2o/core/sparse_block_matrix.hpp +++ b/Thirdparty/g2o/g2o/core/sparse_block_matrix.hpp @@ -648,7 +648,7 @@ namespace g2o { destColumnMap.insert(sparseRowSorted[0]); for (size_t j = 1; j < sparseRowSorted.size(); ++j) { typename SparseBlockMatrix::IntBlockMap::iterator hint = destColumnMap.end(); - --hint; // cppreference says the element goes after the hint (until C++11) + --hint; // cppreference says the element goes after the hint (until c++14) destColumnMap.insert(hint, sparseRowSorted[j]); } } diff --git a/include/LoopClosing.h b/include/LoopClosing.h index 7eb0416b15..c3adf13acd 100644 --- a/include/LoopClosing.h +++ b/include/LoopClosing.h @@ -47,7 +47,7 @@ class LoopClosing typedef pair,int> ConsistentGroup; typedef map, - Eigen::aligned_allocator > > KeyFrameAndPose; + Eigen::aligned_allocator > > KeyFrameAndPose; public: diff --git a/include/ORBextractor.h b/include/ORBextractor.h index 66e8e7a547..268148a1ee 100644 --- a/include/ORBextractor.h +++ b/include/ORBextractor.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace ORB_SLAM2 diff --git a/include/PnPsolver.h b/include/PnPsolver.h index f92544fc8f..2db4feb31c 100644 --- a/include/PnPsolver.h +++ b/include/PnPsolver.h @@ -93,16 +93,16 @@ class PnPsolver { void choose_control_points(void); void compute_barycentric_coordinates(void); - void fill_M(CvMat * M, const int row, const double * alphas, const double u, const double v); + void fill_M(cv::Mat * M, const int row, const double * alphas, const double u, const double v); void compute_ccs(const double * betas, const double * ut); void compute_pcs(void); void solve_for_sign(void); - void find_betas_approx_1(const CvMat * L_6x10, const CvMat * Rho, double * betas); - void find_betas_approx_2(const CvMat * L_6x10, const CvMat * Rho, double * betas); - void find_betas_approx_3(const CvMat * L_6x10, const CvMat * Rho, double * betas); - void qr_solve(CvMat * A, CvMat * b, CvMat * X); + void find_betas_approx_1(const cv::Mat * L_6x10, const cv::Mat * Rho, double * betas); + void find_betas_approx_2(const cv::Mat * L_6x10, const cv::Mat * Rho, double * betas); + void find_betas_approx_3(const cv::Mat * L_6x10, const cv::Mat * Rho, double * betas); + void qr_solve(cv::Mat * A, cv::Mat * b, cv::Mat * X); double dot(const double * v1, const double * v2); double dist2(const double * p1, const double * p2); @@ -110,9 +110,9 @@ class PnPsolver { void compute_rho(double * rho); void compute_L_6x10(const double * ut, double * l_6x10); - void gauss_newton(const CvMat * L_6x10, const CvMat * Rho, double current_betas[4]); + void gauss_newton(const cv::Mat * L_6x10, const cv::Mat * Rho, double current_betas[4]); void compute_A_and_b_gauss_newton(const double * l_6x10, const double * rho, - double cb[4], CvMat * A, CvMat * b); + double cb[4], cv::Mat * A, cv::Mat * b); double compute_R_and_t(const double * ut, const double * betas, double R[3][3], double t[3]); diff --git a/include/System.h b/include/System.h index b377b453d1..e05aa8eec4 100644 --- a/include/System.h +++ b/include/System.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "Tracking.h" #include "FrameDrawer.h" diff --git a/src/FrameDrawer.cc b/src/FrameDrawer.cc index e23b86c207..6a90b6afe4 100644 --- a/src/FrameDrawer.cc +++ b/src/FrameDrawer.cc @@ -72,7 +72,7 @@ cv::Mat FrameDrawer::DrawFrame() } // destroy scoped mutex -> release mutex if(im.channels()<3) //this should be always true - cvtColor(im,im,CV_GRAY2BGR); + cvtColor(im,im,cv::COLOR_GRAY2BGR); //Draw if(state==Tracking::NOT_INITIALIZED) //INITIALIZING diff --git a/src/LocalMapping.cc b/src/LocalMapping.cc index 6c87a6e55a..5396402c5b 100644 --- a/src/LocalMapping.cc +++ b/src/LocalMapping.cc @@ -24,6 +24,7 @@ #include "Optimizer.h" #include +#include namespace ORB_SLAM2 { diff --git a/src/PnPsolver.cc b/src/PnPsolver.cc index af3511b165..88efabd7f4 100644 --- a/src/PnPsolver.cc +++ b/src/PnPsolver.cc @@ -385,21 +385,19 @@ void PnPsolver::choose_control_points(void) // Take C1, C2, and C3 from PCA on the reference points: - CvMat * PW0 = cvCreateMat(number_of_correspondences, 3, CV_64F); + cv::Mat PW0 = cv::Mat(number_of_correspondences, 3, CV_64F); double pw0tpw0[3 * 3], dc[3], uct[3 * 3]; - CvMat PW0tPW0 = cvMat(3, 3, CV_64F, pw0tpw0); - CvMat DC = cvMat(3, 1, CV_64F, dc); - CvMat UCt = cvMat(3, 3, CV_64F, uct); + cv::Mat PW0tPW0 = cv::Mat(3, 3, CV_64F, pw0tpw0); + cv::Mat DC = cv::Mat(3, 1, CV_64F, dc); + cv::Mat UCt = cv::Mat(3, 3, CV_64F, uct); for(int i = 0; i < number_of_correspondences; i++) for(int j = 0; j < 3; j++) - PW0->data.db[3 * i + j] = pws[3 * i + j] - cws[0][j]; + PW0.at(3 * i + j) = pws[3 * i + j] - cws[0][j]; - cvMulTransposed(PW0, &PW0tPW0, 1); - cvSVD(&PW0tPW0, &DC, &UCt, 0, CV_SVD_MODIFY_A | CV_SVD_U_T); - - cvReleaseMat(&PW0); + cv::mulTransposed(PW0, PW0tPW0, 1); + cv::SVD::compute(PW0tPW0, DC, UCt, cv::Mat(), cv::SVD::MODIFY_A | cv::SVD::NO_UV); for(int i = 1; i < 4; i++) { double k = sqrt(dc[i - 1] / number_of_correspondences); @@ -411,14 +409,14 @@ void PnPsolver::choose_control_points(void) void PnPsolver::compute_barycentric_coordinates(void) { double cc[3 * 3], cc_inv[3 * 3]; - CvMat CC = cvMat(3, 3, CV_64F, cc); - CvMat CC_inv = cvMat(3, 3, CV_64F, cc_inv); + cv::Mat CC = cv::Mat(3, 3, CV_64F, cc); + cv::Mat CC_inv = cv::Mat(3, 3, CV_64F, cc_inv); for(int i = 0; i < 3; i++) for(int j = 1; j < 4; j++) cc[3 * i + j - 1] = cws[j][i] - cws[0][i]; - cvInvert(&CC, &CC_inv, CV_SVD); + cv::invert(CC, CC_inv, cv::DECOMP_SVD); double * ci = cc_inv; for(int i = 0; i < number_of_correspondences; i++) { double * pi = pws + 3 * i; @@ -433,10 +431,10 @@ void PnPsolver::compute_barycentric_coordinates(void) } } -void PnPsolver::fill_M(CvMat * M, +void PnPsolver::fill_M(cv::Mat * M, const int row, const double * as, const double u, const double v) { - double * M1 = M->data.db + row * 12; + double * M1 = M->ptr(row * 12); double * M2 = M1 + 12; for(int i = 0; i < 4; i++) { @@ -479,23 +477,22 @@ double PnPsolver::compute_pose(double R[3][3], double t[3]) choose_control_points(); compute_barycentric_coordinates(); - CvMat * M = cvCreateMat(2 * number_of_correspondences, 12, CV_64F); + cv::Mat M = cv::Mat(2 * number_of_correspondences, 12, CV_64F); for(int i = 0; i < number_of_correspondences; i++) - fill_M(M, 2 * i, alphas + 4 * i, us[2 * i], us[2 * i + 1]); + fill_M(&M, 2 * i, alphas + 4 * i, us[2 * i], us[2 * i + 1]); double mtm[12 * 12], d[12], ut[12 * 12]; - CvMat MtM = cvMat(12, 12, CV_64F, mtm); - CvMat D = cvMat(12, 1, CV_64F, d); - CvMat Ut = cvMat(12, 12, CV_64F, ut); + cv::Mat MtM = cv::Mat(12, 12, CV_64F, mtm); + cv::Mat D = cv::Mat(12, 1, CV_64F, d); + cv::Mat Ut = cv::Mat(12, 12, CV_64F, ut); - cvMulTransposed(M, &MtM, 1); - cvSVD(&MtM, &D, &Ut, 0, CV_SVD_MODIFY_A | CV_SVD_U_T); - cvReleaseMat(&M); + cv::mulTransposed(M, MtM, 1); + cv::SVD::compute(MtM, D, Ut, cv::Mat(), cv::SVD::MODIFY_A | cv::SVD::NO_UV); double l_6x10[6 * 10], rho[6]; - CvMat L_6x10 = cvMat(6, 10, CV_64F, l_6x10); - CvMat Rho = cvMat(6, 1, CV_64F, rho); + cv::Mat L_6x10 = cv::Mat(6, 10, CV_64F, l_6x10); + cv::Mat Rho = cv::Mat(6, 1, CV_64F, rho); compute_L_6x10(ut, l_6x10); compute_rho(rho); @@ -588,12 +585,12 @@ void PnPsolver::estimate_R_and_t(double R[3][3], double t[3]) } double abt[3 * 3], abt_d[3], abt_u[3 * 3], abt_v[3 * 3]; - CvMat ABt = cvMat(3, 3, CV_64F, abt); - CvMat ABt_D = cvMat(3, 1, CV_64F, abt_d); - CvMat ABt_U = cvMat(3, 3, CV_64F, abt_u); - CvMat ABt_V = cvMat(3, 3, CV_64F, abt_v); + cv::Mat ABt = cv::Mat(3, 3, CV_64F, abt); + cv::Mat ABt_D = cv::Mat(3, 1, CV_64F, abt_d); + cv::Mat ABt_U = cv::Mat(3, 3, CV_64F, abt_u); + cv::Mat ABt_V = cv::Mat(3, 3, CV_64F, abt_v); - cvSetZero(&ABt); + ABt.setTo(0); for(int i = 0; i < number_of_correspondences; i++) { double * pc = pcs + 3 * i; double * pw = pws + 3 * i; @@ -605,7 +602,7 @@ void PnPsolver::estimate_R_and_t(double R[3][3], double t[3]) } } - cvSVD(&ABt, &ABt_D, &ABt_U, &ABt_V, CV_SVD_MODIFY_A); + cv::SVD::compute(ABt, ABt_D, ABt_U, ABt_V, cv::SVD::MODIFY_A); for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) @@ -664,21 +661,21 @@ double PnPsolver::compute_R_and_t(const double * ut, const double * betas, // betas10 = [B11 B12 B22 B13 B23 B33 B14 B24 B34 B44] // betas_approx_1 = [B11 B12 B13 B14] -void PnPsolver::find_betas_approx_1(const CvMat * L_6x10, const CvMat * Rho, +void PnPsolver::find_betas_approx_1(const cv::Mat * L_6x10, const cv::Mat * Rho, double * betas) { double l_6x4[6 * 4], b4[4]; - CvMat L_6x4 = cvMat(6, 4, CV_64F, l_6x4); - CvMat B4 = cvMat(4, 1, CV_64F, b4); - - for(int i = 0; i < 6; i++) { - cvmSet(&L_6x4, i, 0, cvmGet(L_6x10, i, 0)); - cvmSet(&L_6x4, i, 1, cvmGet(L_6x10, i, 1)); - cvmSet(&L_6x4, i, 2, cvmGet(L_6x10, i, 3)); - cvmSet(&L_6x4, i, 3, cvmGet(L_6x10, i, 6)); + cv::Mat L_6x4 = cv::Mat(6, 4, CV_64F, l_6x4); + cv::Mat B4 = cv::Mat(4, 1, CV_64F, b4); + + for (int i = 0; i < 6; i++) { + L_6x4.at(i, 0) = L_6x10->at(i, 0); + L_6x4.at(i, 1) = L_6x10->at(i, 1); + L_6x4.at(i, 2) = L_6x10->at(i, 3); + L_6x4.at(i, 3) = L_6x10->at(i, 6); } - cvSolve(&L_6x4, Rho, &B4, CV_SVD); + cv::solve(L_6x4, *Rho, B4, cv::DECOMP_SVD); if (b4[0] < 0) { betas[0] = sqrt(-b4[0]); @@ -696,20 +693,20 @@ void PnPsolver::find_betas_approx_1(const CvMat * L_6x10, const CvMat * Rho, // betas10 = [B11 B12 B22 B13 B23 B33 B14 B24 B34 B44] // betas_approx_2 = [B11 B12 B22 ] -void PnPsolver::find_betas_approx_2(const CvMat * L_6x10, const CvMat * Rho, +void PnPsolver::find_betas_approx_2(const cv::Mat * L_6x10, const cv::Mat * Rho, double * betas) { double l_6x3[6 * 3], b3[3]; - CvMat L_6x3 = cvMat(6, 3, CV_64F, l_6x3); - CvMat B3 = cvMat(3, 1, CV_64F, b3); + cv::Mat L_6x3 = cv::Mat(6, 3, CV_64F, l_6x3); + cv::Mat B3 = cv::Mat(3, 1, CV_64F, b3); for(int i = 0; i < 6; i++) { - cvmSet(&L_6x3, i, 0, cvmGet(L_6x10, i, 0)); - cvmSet(&L_6x3, i, 1, cvmGet(L_6x10, i, 1)); - cvmSet(&L_6x3, i, 2, cvmGet(L_6x10, i, 2)); + L_6x3.at(i, 0) = L_6x10->at(i, 0); + L_6x3.at(i, 1) = L_6x10->at(i, 1); + L_6x3.at(i, 2) = L_6x10->at(i, 2); } - cvSolve(&L_6x3, Rho, &B3, CV_SVD); + cv::solve(L_6x3, *Rho, B3, cv::DECOMP_SVD); if (b3[0] < 0) { betas[0] = sqrt(-b3[0]); @@ -728,22 +725,22 @@ void PnPsolver::find_betas_approx_2(const CvMat * L_6x10, const CvMat * Rho, // betas10 = [B11 B12 B22 B13 B23 B33 B14 B24 B34 B44] // betas_approx_3 = [B11 B12 B22 B13 B23 ] -void PnPsolver::find_betas_approx_3(const CvMat * L_6x10, const CvMat * Rho, +void PnPsolver::find_betas_approx_3(const cv::Mat * L_6x10, const cv::Mat * Rho, double * betas) { double l_6x5[6 * 5], b5[5]; - CvMat L_6x5 = cvMat(6, 5, CV_64F, l_6x5); - CvMat B5 = cvMat(5, 1, CV_64F, b5); + cv::Mat L_6x5 = cv::Mat(6, 5, CV_64F, l_6x5); + cv::Mat B5 = cv::Mat(5, 1, CV_64F, b5); for(int i = 0; i < 6; i++) { - cvmSet(&L_6x5, i, 0, cvmGet(L_6x10, i, 0)); - cvmSet(&L_6x5, i, 1, cvmGet(L_6x10, i, 1)); - cvmSet(&L_6x5, i, 2, cvmGet(L_6x10, i, 2)); - cvmSet(&L_6x5, i, 3, cvmGet(L_6x10, i, 3)); - cvmSet(&L_6x5, i, 4, cvmGet(L_6x10, i, 4)); + L_6x5.at(i, 0) = L_6x10->at(i, 0); + L_6x5.at(i, 1) = L_6x10->at(i, 1); + L_6x5.at(i, 2) = L_6x10->at(i, 2); + L_6x5.at(i, 3) = L_6x10->at(i, 3); + L_6x5.at(i, 4) = L_6x10->at(i, 4); } - cvSolve(&L_6x5, Rho, &B5, CV_SVD); + cv::solve(L_6x5, *Rho, B5, cv::SVD::NO_UV); if (b5[0] < 0) { betas[0] = sqrt(-b5[0]); @@ -810,18 +807,18 @@ void PnPsolver::compute_rho(double * rho) } void PnPsolver::compute_A_and_b_gauss_newton(const double * l_6x10, const double * rho, - double betas[4], CvMat * A, CvMat * b) + double betas[4], cv::Mat * A, cv::Mat * b) { for(int i = 0; i < 6; i++) { const double * rowL = l_6x10 + i * 10; - double * rowA = A->data.db + i * 4; + double * rowA = A->ptr(i * 4); rowA[0] = 2 * rowL[0] * betas[0] + rowL[1] * betas[1] + rowL[3] * betas[2] + rowL[6] * betas[3]; rowA[1] = rowL[1] * betas[0] + 2 * rowL[2] * betas[1] + rowL[4] * betas[2] + rowL[7] * betas[3]; rowA[2] = rowL[3] * betas[0] + rowL[4] * betas[1] + 2 * rowL[5] * betas[2] + rowL[8] * betas[3]; rowA[3] = rowL[6] * betas[0] + rowL[7] * betas[1] + rowL[8] * betas[2] + 2 * rowL[9] * betas[3]; - cvmSet(b, i, 0, rho[i] - + b->at(i, 0) = rho[i] - ( rowL[0] * betas[0] * betas[0] + rowL[1] * betas[0] * betas[1] + @@ -833,22 +830,22 @@ void PnPsolver::compute_A_and_b_gauss_newton(const double * l_6x10, const double rowL[7] * betas[1] * betas[3] + rowL[8] * betas[2] * betas[3] + rowL[9] * betas[3] * betas[3] - )); + ); } } -void PnPsolver::gauss_newton(const CvMat * L_6x10, const CvMat * Rho, +void PnPsolver::gauss_newton(const cv::Mat * L_6x10, const cv::Mat * Rho, double betas[4]) { const int iterations_number = 5; double a[6*4], b[6], x[4]; - CvMat A = cvMat(6, 4, CV_64F, a); - CvMat B = cvMat(6, 1, CV_64F, b); - CvMat X = cvMat(4, 1, CV_64F, x); + cv::Mat A = cv::Mat(6, 4, CV_64F, a); + cv::Mat B = cv::Mat(6, 1, CV_64F, b); + cv::Mat X = cv::Mat(4, 1, CV_64F, x); for(int k = 0; k < iterations_number; k++) { - compute_A_and_b_gauss_newton(L_6x10->data.db, Rho->data.db, + compute_A_and_b_gauss_newton(L_6x10->ptr(0), Rho->ptr(), betas, &A, &B); qr_solve(&A, &B, &X); @@ -857,7 +854,7 @@ void PnPsolver::gauss_newton(const CvMat * L_6x10, const CvMat * Rho, } } -void PnPsolver::qr_solve(CvMat * A, CvMat * b, CvMat * X) +void PnPsolver::qr_solve(cv::Mat * A, cv::Mat * b, cv::Mat * X) { static int max_nr = 0; static double * A1, * A2; @@ -875,7 +872,7 @@ void PnPsolver::qr_solve(CvMat * A, CvMat * b, CvMat * X) A2 = new double[nr]; } - double * pA = A->data.db, * ppAkk = pA; + double * pA = A->ptr(0), *ppAkk = pA; for(int k = 0; k < nc; k++) { double * ppAik = ppAkk, eta = fabs(*ppAik); for(int i = k + 1; i < nr; i++) { @@ -919,7 +916,7 @@ void PnPsolver::qr_solve(CvMat * A, CvMat * b, CvMat * X) } // b <- Qt b - double * ppAjj = pA, * pb = b->data.db; + double * ppAjj = pA, *pb = b->ptr(0); for(int j = 0; j < nc; j++) { double * ppAij = ppAjj, tau = 0; for(int i = j; i < nr; i++) { @@ -936,7 +933,7 @@ void PnPsolver::qr_solve(CvMat * A, CvMat * b, CvMat * X) } // X = R-1 b - double * pX = X->data.db; + double * pX = X->ptr(0); pX[nc - 1] = pb[nc - 1] / A2[nc - 1]; for(int i = nc - 2; i >= 0; i--) { double * ppAij = pA + i * nc + (i + 1), sum = 0; diff --git a/src/Sim3Solver.cc b/src/Sim3Solver.cc index 4ad44ff0de..0ff7e733e8 100644 --- a/src/Sim3Solver.cc +++ b/src/Sim3Solver.cc @@ -214,7 +214,7 @@ cv::Mat Sim3Solver::find(vector &vbInliers12, int &nInliers) void Sim3Solver::ComputeCentroid(cv::Mat &P, cv::Mat &Pr, cv::Mat &C) { - cv::reduce(P,C,1,CV_REDUCE_SUM); + cv::reduce(P,C,1,cv::REDUCE_SUM); C = C/P.cols; for(int i=0; i1e-5) || imDepth.type()!=CV_32F) @@ -242,16 +242,16 @@ cv::Mat Tracking::GrabImageMonocular(const cv::Mat &im, const double ×tamp) if(mImGray.channels()==3) { if(mbRGB) - cvtColor(mImGray,mImGray,CV_RGB2GRAY); + cvtColor(mImGray,mImGray,cv::COLOR_RGB2GRAY); else - cvtColor(mImGray,mImGray,CV_BGR2GRAY); + cvtColor(mImGray,mImGray,cv::COLOR_BGR2GRAY); } else if(mImGray.channels()==4) { if(mbRGB) - cvtColor(mImGray,mImGray,CV_RGBA2GRAY); + cvtColor(mImGray,mImGray,cv::COLOR_RGBA2GRAY); else - cvtColor(mImGray,mImGray,CV_BGRA2GRAY); + cvtColor(mImGray,mImGray,cv::COLOR_BGRA2GRAY); } if(mState==NOT_INITIALIZED || mState==NO_IMAGES_YET)