安装支持eigen线性迭代的ceres_solver
Ceres可以求解以下形式的有界约束非线性最小二乘问题:
这种形式的问题来源于科学工程的多个领域,从统计学的曲线拟合到计算机视觉中从图像中构建三维模型。
最近在做sfm方面的重建问题,需要对得到的相机位姿和3维点做BA优化,ceres-solver和g2o都能做ba
ceres-solver是有依赖项eigen的,而且Ceres can also use Eigen as a sparse linear algebra library.
但是EIGENSPARSE 在camke的时候是默认关闭的,所以当我在程序中调用
ceres_config_options.sparse_linear_algebra_library_type = ceres::EIGEN_SPARSE;
编译无错,能编译成功,但是调用的时候,会报错
E0606 14:09:29.387037 9074 solver.cc:487] Terminating: Can't use SPARSE_SCHUR with EIGEN_SPARSE because Eigen's sparse linear algebra was not enabled when Ceres was built. Bundle Adjustment failed.
所以解决方案只能把ceres-solver重新装一遍
1.卸载
进入ceres-solver的编译文件夹,执行卸载命令
cd ceres-solver/build
sudo make uninstall
执行命令之后就可以完全卸载成功了。
2.安装ceres-solver
安装之前请确保你已经安装了ceres-solver的依赖项,因为我装过,所以不用再装依赖项了,你可以安装以下命令安装,
可以参考官方文档:http://www.ceres-solver.org/installation.html
# CMake sudo apt-get install cmake # google-glog + gflags sudo apt-get install libgoogle-glog-dev # BLAS & LAPACK sudo apt-get install libatlas-base-dev # Eigen3 sudo apt-get install libeigen3-dev # SuiteSparse and CXSparse (optional) # - If you want to build Ceres as a *static* library (the default) # you can use the SuiteSparse package in the main Ubuntu package # repository: sudo apt-get install libsuitesparse-dev # - However, if you want to build Ceres as a *shared* library, you must # add the following PPA: sudo add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687 sudo apt-get update sudo apt-get install libsuitesparse-dev
3.编译安装
以上步骤都完成后就可以编译安装ceres-solver了,cmake的时候要把 EIGENSPARSE
设置为 ON,进入到编译目录,执行命令
cd ceres-solver/build cmake -D EIGENSPARSE=ON .. make sudo make install
这样就可以编译成功了
参考:http://www.ceres-solver.org/installation.html