本文是参照ceres-solver的官方网站的按照教程来写的,并对其做了适当的修改以便能成功安装。ceres官方教程链接为http://www.ceres-solver.org/installation.html#linux。
sudo apt-get install cmake
sudo apt-get install libgoogle-glog-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libsuitesparse-dev
sudo add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687
sudo apt-get update
sudo apt-get install libsuitesparse-dev
在ubuntu终端输入以上代码,基本不会出现什么error。
接下来,就是下载ceres-solver的安装包了,安装包官方下载地址如下:https://github.com/ceres-solver/ceres-solver。
点击右上角绿色按钮Clone or Download,然后选择Download ZIP。
第一步,解压下载下来的ceres-solver-master.zip安装包。第二步,利用filezilla软件,将解压之后的文件夹ceres-solver-master传送到linux ubuntu中去。目录可以自己选择,我存放的目录是/home/gnc/Downloads。其中gnc为用户名。第三步,重命名文件夹为ceres-solver-1.14.0。在终端中输入
mv /home/gnc/Downloads/ceres-solver-master /home/gnc/Downloads/ceres-solver-1.14.0
就行了。
在终端中输入
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver-1.14.0
make -j3
make test
sudo make install
这样就安装成功了。
于是乎,在终端中输入
bin/simple_bundle_adjuster ../ceres-solver-1.14.0/data/problem-16-22106-pre.txt
如果安装成功的话,会出现如下结果:
iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time
0 4.185660e+06 0.00e+00 1.09e+08 0.00e+00 0.00e+00 1.00e+04 0 3.03e-01 8.87e-01
1 1.062590e+05 4.08e+06 8.99e+06 5.36e+02 9.82e-01 3.00e+04 1 6.70e-01 1.56e+00
2 4.992817e+04 5.63e+04 8.32e+06 3.19e+02 6.52e-01 3.09e+04 1 6.47e-01 2.20e+00
3 1.899774e+04 3.09e+04 1.60e+06 1.24e+02 9.77e-01 9.26e+04 1 6.47e-01 2.85e+00
4 1.808729e+04 9.10e+02 3.97e+05 6.39e+01 9.51e-01 2.78e+05 1 6.47e-01 3.50e+00
5 1.803399e+04 5.33e+01 1.48e+04 1.23e+01 9.99e-01 8.33e+05 1 6.47e-01 4.15e+00
6 1.803390e+04 9.02e-02 6.35e+01 8.00e-01 1.00e+00 2.50e+06 1 6.47e-01 4.79e+00
Solver Summary (v 2.0.0-eigen-(3.3.4)-lapack-suitesparse-(5.1.2)-cxsparse-(3.1.9)-eigensparse-no_openmp)
Original Reduced
Parameter blocks 22122 22122
Parameters 66462 66462
Residual blocks 83718 83718
Residuals 167436 167436
Minimizer TRUST_REGION
Dense linear algebra library EIGEN
Trust region strategy LEVENBERG_MARQUARDT
Given Used
Linear solver DENSE_SCHUR DENSE_SCHUR
Threads 1 1
Linear solver ordering AUTOMATIC 22106,16
Schur structure 2,3,9 2,3,9
Cost:
Initial 4.185660e+06
Final 1.803390e+04
Change 4.167626e+06
Minimizer iterations 7
Successful steps 7
Unsuccessful steps 0
Time (in seconds):
Preprocessor 0.583811
Residual only evaluation 0.480404 (7)
Jacobian & residual evaluation 1.817008 (7)
Linear solver 1.930402 (7)
Minimizer 4.585502
Postprocessor 0.033484
Total 5.202797
Termination: CONVERGENCE (Function tolerance reached. |cost_change|/cost: 1.769761e-09 <= 1.000000e-06)
到此结束。