Berkeley SfM
bundle_adjustment_options.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, The Regents of the University of California (Regents).
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer in the documentation and/or other materials provided
15  * with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Please contact the author(s) of this library if you have any questions.
34  * Authors: Erik Nelson ( eanelson@eecs.berkeley.edu )
35  * David Fridovich-Keil ( dfk@eecs.berkeley.edu )
36  */
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 //
40 // This struct defines a set of options that are used during bundle adjustment.
41 // Most of the options define the behavior of the non-linear least-squares
42 // optimization, which is performed by Ceres. More details on these options can
43 // be found at: http://ceres-solver.org/nnls_solving.html#solver-options
44 //
45 ///////////////////////////////////////////////////////////////////////////////
46 
47 #ifndef BSFM_SFM_BUNDLE_ADJUSTMENT_OPTIONS_H
48 #define BSFM_SFM_BUNDLE_ADJUSTMENT_OPTIONS_H
49 
50 #include <string>
51 
52 namespace bsfm {
53 
55  // Set ceres solver type. DENSE_SCHUR and SPARSE_SCHUR are good solvers for
56  // bundle adjustment problems, where DENSE_SCHUR will be faster for problems
57  // with roughly the same number of cameras and points. However, most bundle
58  // adjustment problems have number of cameras << number of points, and in this
59  // case SPARSE_SCHUR will be faster. CGNR is also a good choice. Valid options
60  // (as well as benchmark time using 100 points and 100 cameras) are:
61  // - DENSE_QR - 19.011 seconds
62  // - DENSE_NORMAL_CHOLESKY - 1.587 seconds
63  // - SPARSE_NORMAL_CHOLESKY - 0.044 seconds
64  // - CGNR - 0.028 seconds
65  // - DENSE_SCHUR - 0.050 seconds
66  // - SPARSE_SCHUR - 0.110 seconds
67  // - ITERATIVE_SCHUR - 0.026 seconds
68  std::string solver_type = "SPARSE_SCHUR";
69 
70  // Print the full ceres report after finishing bundle adjustment.
71  bool print_summary = false;
72 
73  // Print optimization progress as ceres is solving.
74  bool print_progress = false;
75 
76  // Maximum number of steps that the optimizer will take.
77  unsigned int max_num_iterations = 50;
78 
79  // The solver will terminate if | delta cost | / cost < function_tolerance.
80  double function_tolerance = 1e-16;
81 
82  // The solver will terminate if the computed gradient is less than this.
83  double gradient_tolerance = 1e-16;
84 
85  // TODO(eanelson): Add option to optimize camera parameters, e.g. focal
86  // length, skew, aspect ratio, radial distortion, principal point.
87 
88 }; //\struct BundleAdjustmentOptions
89 
90 } //\namespace bsfm
91 
92 #endif
Definition: camera.cpp:50