第六章
ceres环境配置
下载地址:
git clone https://github.com/ceres-solver/ceres-solver
安装附加库前需要安装依赖项,依赖项会报错。解决:
//第一步,打开sources.list
sudo gedit /etc/apt/sources.list
//第二步,将下面的源粘贴到最上方sources.list
deb http://cz.archive.ubuntu.com/ubuntu trusty main universe
//第三步,更新源(看网速,差不多10分钟)
sudo apt-get update
//第四步,重新输入依赖项安装命令安装依赖项
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.2 libgflags-dev libgoogle-glog-dev libgtest-dev
#进入到解压后的压缩文件夹中,进行编译:(预计10分钟)
mkdir build
cd build
cmake ..
make -j4
#然后执行:
sudo make install
sudo ldconfig
#验证是否安装成功:
/usr/local/include/ceres有ceres的头文件,/usr/local/lib/下能找到名为libceres.a的库文件
以上是ceres的配置
g2o 的环境配置
安装包下载地址:
https://github.com/RainerKuemmerle/g2o/tree/9b41a4ea5ade8e1250b9c1b279f3a9c098811b5a
下载后的安装包拷贝到虚拟机,解压
sudo apt-get install libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev-qt5
(注:libqglviewer-dev这个会处理不了依赖,改为最后一个)
#之前克隆的目录
mkdir build
cd build
cmake ..
make -j4
sudo make install
安装成功会在/usr/local/include/g2o的文件夹
/usr/local/lib下会出现一堆libg2o
安装g2o库时缺少矩阵某函数,关于g2o的初始化问题。
细节解释参考https://www.cnblogs.com/xueyuanaichiyu/p/7921382.html
然后跳转到实例g2o_curve_fitting
mkdir build
cd build/
cmake ..
make
ls
./各种绿色二进制文件
实例第七章
feature_extraction
CMakeLists.txt中(因为之前安装的是opencv4)
set(CMAKE_CXX_FLAGS "-std=c++11 -O2 ${SSE_FLAGS} -msse4")
find_package( OpenCV 3.1 REQUIRED )
"/usr/include/eigen3/"
改为
set(CMAKE_CXX_FLAGS "-std=c++17 ${SSE_FLAGS} -msse4")
find_package( OpenCV 4 REQUIRED )
"/usr/local/include/eigen3/"
报错关于:CV_LOAD_IMAGE_COLOR,加入头文件
在所有c文件和h文件的前面加入
#include "opencv2/imgcodecs/legacy/constants_c.h"
报错关于 error: ‘CV_FM_8POINT’
pose_estimation_2d2d.cpp ,extra.cpp,pose_estimation_2d2d.cpp,triangulation.cpp中
fundamental_matrix = findFundamentalMat ( points1, points2, CV_FM_8POINT );
修改为
fundamental_matrix = findFundamentalMat ( points1, points2, FM_8POINT );
路径修改
orb_self.cpp
string first_file = "./1.png";
string second_file = "./2.png";
修改为
string first_file = "../1.png";
string second_file = "../2.png";
代码错误
orb_cv.cpp中
cout << "usage: feature_extraction img1 img2" << endl;
修改为
cout << "usage: orb_cv img1 img2" << endl;
重新编译
mkdir build
cd build/
cmake ..
make
ls
./orb_cv ../1.png ../2.png
./orb_self
./pose_estimation_2d2d ../1.png ../2.png
./pose_estimation_3d2d ../1.png ../2.png ../1_depth.png ../2_depth.png
./pose_estimation_3d3d ../1.png ../2.png ../1_depth.png ../2_depth.png
./triangulation ../1.png ../2.png
第八章
cmakelist.txt
set(CMAKE_CXX_FLAGS "-std=c++11 ${SSE_FLAGS} -g -O3 -march=native")
"/usr/include/eigen3/"
修改为
set(CMAKE_CXX_FLAGS "-std=c++17 ${SSE_FLAGS} -g -O3 -march=native")
"/usr/local/include/eigen3/"
opencv4命令与opencv2有所不同,但cmakelist.txt却写了opencv4,所以要有4的语法
optical_flow.cpp下
cv::cvtColor(img2, img2_CV, CV_GRAY2BGR);
cv::cvtColor(img2, img2_multi, CV_GRAY2BGR);
cv::cvtColor(img2, img2_single, CV_GRAY2BGR);
string file_1 = "./LK1.png"; // first image
string file_2 = "./LK2.png"; // second image
改成
cv::cvtColor(img2, img2_CV, COLOR_GRAY2BGR);
cv::cvtColor(img2, img2_multi, COLOR_GRAY2BGR);
cv::cvtColor(img2, img2_single, COLOR_GRAY2BGR);
string file_1 = "../LK1.png"; // first image
string file_2 = "../LK2.png"; // second image
direct_method.cpp下
cv::cvtColor(img2, img2_show, CV_GRAY2BGR);
string left_file = "./left.png";
string disparity_file = "./disparity.png";
boost::format fmt_others("./%06d.png"); // other files
改成
cv::cvtColor(img2, img2_show, cv::COLOR_GRAY2BGR);
string left_file = "../left.png";
string disparity_file = "../disparity.png";
boost::format fmt_others("../%06d.png"); // other files
mkdir build
cd build/
cmake ..
make
./optical_flow
./direct_method
然后一直回车
第八章后面暂停更新。