Introduction
Ceres is a new C++ library and optimization software for nonlinear least squares problems. It is aimed for fitting models in statistics and finds use in computer vision at Google. It was released as an open source software with BSD license by Google and was developed by Sameer Aggarwal and Keir Mierle. The home page is athttp://code.google.com/p/ceres-solver/. The following are features of Ceres:
- A friendly API: build your cost function one residual at a time
- Automatic differentiation
- Robust loss functions
- Local parameterizations
- Threaded Jacobian evaluators and linear solvers
- Dense QR factorization (using Eigen) for small problems
- Sparse Cholesky factorization (using SuiteSparse) for large sparse problems
- Specialized solvers for bundle adjustment problems in computer vision.
- Scales from servers to cell phones.
- Supports Linux and MacOS with future support for Windows and iOS and Android.
Installing Ceres using a terminal
1. Create a subdirectory ceres-1.0 and cd to that created directory. 2. Download using wget.$mkdir ceres-1.0 $ cd ceres-1.0 $ wget -ct 0 http://ceres-solver.googlecode.com/files/ceres-solver-1.0.0.tar.gz wget -ct 0 http://ceres-solver.googlecode.com/files/ceres-solver-1.0.0.tar.gz --2012-05-11 15:09:52-- http://ceres-solver.googlecode.com/files/ceres-solver-1.0.0.tar.gz Resolving ceres-solver.googlecode.com... 209.85.175.82 Connecting to ceres-solver.googlecode.com|209.85.175.82|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 3461260 (3.3M) [application/x-gzip] Saving to: `ceres-solver-1.0.0.tar.gz' 100%[====================================================================================>] 3,461,260 65.1K/s in 54s 2012-05-11 15:10:47 (62.2 KB/s) - `ceres-solver-1.0.0.tar.gz' saved [3461260/3461260]3. Untar the gzipped file by typing tar xzvvf ceres-solver-1.0.0.tar.gz. Change the current directory to ceres-solver-1.0.0.
Software Dependencies
4. Install various dependency files. You need to install the following softwares in order for Ceres to do its thing: cmake, gflags, glog, eigen , suitesparse and protobuf:sudo apt-get install cmake wget -ct 0 http://gflags.googlecode.com/files/gflags-2.0.tar.gz tar xzvvf gflags-2.0.tar.gz cd gflags-2.0 ./configure --prefix=/usr/local make cd .. wget http://google-glog.googlecode.com/files/glog-0.3.2.tar.gz tar xzvvf glog-0.3.2.tar.gz cd glog-0.3.2/ ./configure --with-gflags=/usr/local/ make sudo make install sudo apt-get install libeigen3-dev sudo apt-get install libsuitesparse-dev sudo apt-get install libprotobuf-dev
5. Now it is time to install the Ceres software.
mkdir ceres-bin cd ceres-bin cmake ../ceres-solver-1.0.0 cmake ../ceres-solver-1.0.0 -DEIGEN_INCLUDE=/usr/include/eigen3 make -j3
Example
6. Running the example:examples/simple_bundle_adjuster ../ceres-solver-1.0.0/data/problem-16-22106-pre.txt 0: f: 1.598216e+06 d: 0.00e+00 g: 5.67e+18 h: 0.00e+00 rho: 0.00e+00 mu: 1.00e-04 li: 0 1: f: 1.116401e+05 d: 1.49e+06 g: 1.42e+18 h: 5.48e+02 rho: 9.50e-01 mu: 3.33e-05 li: 1 2: f: 4.923547e+04 d: 6.24e+04 g: 8.57e+17 h: 3.21e+02 rho: 6.79e-01 mu: 3.18e-05 li: 1 3: f: 1.884538e+04 d: 3.04e+04 g: 1.45e+17 h: 1.25e+02 rho: 9.81e-01 mu: 1.06e-05 li: 1 4: f: 1.807384e+04 d: 7.72e+02 g: 3.88e+16 h: 6.23e+01 rho: 9.57e-01 mu: 3.53e-06 li: 1 5: f: 1.803397e+04 d: 3.99e+01 g: 1.35e+15 h: 1.16e+01 rho: 9.99e-01 mu: 1.18e-06 li: 1 6: f: 1.803390e+04 d: 6.16e-02 g: 6.69e+12 h: 7.31e-01 rho: 1.00e+00 mu: 3.93e-07 li: 1 Ceres Solver Report ------------------- Original Reduced Parameter blocks 22122 22122 Parameters 66462 66462 Residual blocks 83718 83718 Residual 167436 167436 Given Used Linear solver DENSE_SCHUR DENSE_SCHUR Preconditioner N/A N/A Ordering SCHUR SCHUR num_eliminate_blocks N/A 22106 Threads: 1 1 Linear Solver Threads: 1 1 Cost: Initial 1.598216e+06 Final 1.803390e+04 Change 1.580182e+06 Number of iterations: Successful 6 Unsuccessful 0 Total 6 Time (in seconds): Preprocessor 1.000000e+00 Minimizer 5.000000e+00 Total 6.000000e+00 Termination: FUNCTION_TOLERANCE 4520:~/Downloads/ceres-1.0/ceres-bin$In the next part, we explain the example and try to understand the API for using the Ceres Software.