首先是Ubuntu2004 电脑里面有opencv3和opencv4共存,
现象:编译的时候ros指向opencv4版本之间的不兼容导致
源码安装vins-mono算法问题整理(ROS Melodic + opencv 4.1.1) - 创客智造/爱折腾智能机器人社区
测试环境:Jetson Xavier NX+ Jetpack4.4 + Ubuntu 1804 + ROS Melodic + opencv 4.1.1
问题一
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In constructor ‘camodocal::Chessboard::Chessboard(cv::Size, cv::Mat&)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:20:38: error: ‘CV_GRAY2BGR’ was not declared in this scope
cv::cvtColor(image, mSketch, CV_GRAY2BGR);
^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:26:37: error: ‘CV_BGR2GRAY’ was not declared in this scope
cv::cvtColor(image, mImage, CV_BGR2GRAY);
^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘bool camodocal::Chessboard::findChessboardCornersImproved(const cv::Mat&, const Size&, std::vector >&, int)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:150:43: error: ‘CV_BGR2GRAY’ was not declared in this scope
cv::cvtColor(image, norm_img, CV_BGR2GRAY);
^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:207:67: error: ‘CV_THRESH_BINARY’ was not declared in this scope
cv::threshold(img, thresh_img, thresh_level, 255, CV_THRESH_BINARY);
^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In constructor ‘camodocal::Chessboard::Chessboard(cv::Size, cv::Mat&)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:20:38: error: ‘CV_GRAY2BGR’ was not declared in this scope
cv::cvtColor(image, mSketch, CV_GRAY2BGR);
^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:26:37: error: ‘CV_BGR2GRAY’ was not declared in this scope
cv::cvtColor(image, mImage, CV_BGR2GRAY);
^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:215:57: error: ‘CV_SHAPE_CROSS’ was not declared in this scope
cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
^~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘bool camodocal::Chessboard::findChessboardCornersImproved(const cv::Mat&, const Size&, std::vector >&, int)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:150:43: error: ‘CV_BGR2GRAY’ was not declared in this scope
cv::cvtColor(image, norm_img, CV_BGR2GRAY);
^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:215:57: note: suggested alternative: ‘CV_WRAP_AS’
cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
^~~~~~~~~~~~~~
CV_WRAP_AS
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:216:57: error: ‘CV_SHAPE_RECT’ was not declared in this scope
cv::Mat kernel2 = cv::getStructuringElement(CV_SHAPE_RECT, cv::Size(3,3), cv::Point(1,1));
^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:320:43: error: ‘CV_TERMCRIT_EPS’ was not declared in this scope
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
^~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:207:67: error: ‘CV_THRESH_BINARY’ was not declared in this scope
cv::threshold(img, thresh_img, thresh_level, 255, CV_THRESH_BINARY);
^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:320:61: error: ‘CV_TERMCRIT_ITER’ was not declared in this scope
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:215:57: error: ‘CV_SHAPE_CROSS’ was not declared in this scope
cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
^~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:215:57: note: suggested alternative: ‘CV_WRAP_AS’
cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
^~~~~~~~~~~~~~
CV_WRAP_AS
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:216:57: error: ‘CV_SHAPE_RECT’ was not declared in this scope
cv::Mat kernel2 = cv::getStructuringElement(CV_SHAPE_RECT, cv::Size(3,3), cv::Point(1,1));
^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:320:43: error: ‘CV_TERMCRIT_EPS’ was not declared in this scope
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
^~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘void camodocal::Chessboard::generateQuads(std::vector >&, cv::Mat&, int, int, bool)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1175:50: error: ‘CV_RETR_CCOMP’ was not declared in this scope
cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:320:61: error: ‘CV_TERMCRIT_ITER’ was not declared in this scope
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1175:65: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
^~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘void camodocal::Chessboard::generateQuads(std::vector >&, cv::Mat&, int, int, bool)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1175:50: error: ‘CV_RETR_CCOMP’ was not declared in this scope
cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1175:65: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
^~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘bool camodocal::Chessboard::checkChessboard(const cv::Mat&, cv::Size) const’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1586:72: error: ‘CV_THRESH_BINARY’ was not declared in this scope
cv::threshold(white, thresh, threshLevel + blackWhiteGap, 255, CV_THRESH_BINARY);
^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1592:55: error: ‘CV_RETR_CCOMP’ was not declared in this scope
cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1592:70: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
^~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘bool camodocal::Chessboard::checkChessboard(const cv::Mat&, cv::Size) const’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1586:72: error: ‘CV_THRESH_BINARY’ was not declared in this scope
cv::threshold(white, thresh, threshLevel + blackWhiteGap, 255, CV_THRESH_BINARY);
^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1597:56: error: ‘CV_THRESH_BINARY_INV’ was not declared in this scope
cv::threshold(black, thresh, threshLevel, 255, CV_THRESH_BINARY_INV);
^~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1592:55: error: ‘CV_RETR_CCOMP’ was not declared in this scope
cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1592:70: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
^~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1597:56: error: ‘CV_THRESH_BINARY_INV’ was not declared in this scope
cv::threshold(black, thresh, threshLevel, 255, CV_THRESH_BINARY_INV);
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc: In member function ‘void camodocal::CameraCalibration::drawResults(std::vector&) const’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc:236:40: error: ‘CV_GRAY2RGB’ was not declared in this scope
cv::cvtColor(image, image, CV_GRAY2RGB);
^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc:236:40: note: suggested alternative: ‘CV_GRAPH’
cv::cvtColor(image, image, CV_GRAY2RGB);
^~~~~~~~~~~
CV_GRAPH
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc:254:37: error: ‘CV_AA’ was not declared in this scope
5, green, 2, CV_AA, drawShiftBits);
^~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc:254:37: note: suggested alternative: ‘CV_AVX’
5, green, 2, CV_AA, drawShiftBits);
^~~~~
CV_AVX
解决方法
问题二
解决方法
问题三
/home/ubuntu/catkin_ws/src/VINS-Mono/pose_graph/src/ThirdParty/DVision/BRIEF.cpp:53:32: error: ‘CV_RGB2GRAY’ was not declared in this scope cv::cvtColor(image, aux, CV_RGB2GRAY); ^~~~~~~~~~~ /home/ubuntu/catkin_ws/src/VINS-Mono/pose_graph/src/ThirdParty/DVision/BRIEF.cpp:53:32: note: suggested alternative: ‘CV_RGB’ cv::cvtColor(image, aux, CV_RGB2GRAY);
解决方法
问题四
解决方法
error: 'CV_LOAD_IMAGE_GRAYSCALE' was not declared in this scope
CV_LOAD_IMAGE_GRAYSCALE 替换成 cv::IMREAD_GRAYSCALE