I have a simple Bundle adjustment problem, with two cameras, and 230 points that i am trying to solve using Ceres. My goal is to get the absolute fastest solve that i can, but the results that i see seem to contradict the documentation about bundle adjustment problems.
As stated here:
one way to solve this problem is to set Solver::Options::linear_solver_type to SPARSE_NORMAL_CHOLESKY and call Solve(). And while this is a reasonable thing to do, bundle adjustment problems have a special sparsity structure that can be exploited to solve them much more efficiently. Ceres provides three specialized solvers (collectively known as Schur-based solvers) for this task.
However, when I use DENSE_NORMAL_CHOLESKY
, using the solver settings:
options.sparse_linear_algebra_library_type = SUITE_SPARSE;
options.linear_solver_type = ceres::DENSE_NORMAL_CHOLESKY;
options.minimizer_progress_to_stdout = false;
options.logging_type = ceres::SILENT;
options.max_num_iterations = 20;
It gives me:
Time (in seconds):
Preprocessor 0.006372
Residual only evaluation 0.000359 (12)
Jacobian & residual evaluation 0.003254 (12)
Linear solver 0.001549 (12)
Minimizer 0.008216
Postprocessor 0.000008
Total 0.014596
However, when i switch to SCHUR solvers, as below:
options.use_explicit_schur_complement = true;
options.sparse_linear_algebra_library_type = SUITE_SPARSE;
options.linear_solver_type = ceres::ITERATIVE_SCHUR;
options.minimizer_progress_to_stdout = false;
options.logging_type = ceres::SILENT;
options.max_num_iterations = 20;
options.preconditioner_type = SCHUR_JACOBI;
It runs slower, with:
Time (in seconds):
Preprocessor 0.007213
Residual only evaluation 0.000306 (10)
Jacobian & residual evaluation 0.002611 (10)
Linear solver 0.007781 (10)
Minimizer 0.013027
Postprocessor 0.000009
Total 0.020249
Is there anything i can do to get a faster result? I have tried ordering, every kind of linear_solver_type and different pre-conditioners. Setting options.num_threads = 8; makes no noticeable difference either. Am i missing something?
Use analytical derivatives. The bulk of your time is being spent there.