Berkeley SfM
bundle_adjuster.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 class defines a bundle adjustment problem solver. Bundle adjustment is
41 // the problem of determining the 3D positions of n points and the 3D positions
42 // of m cameras simultaneously using features that are matched between the m
43 // views. Bundle adjustment is a non-linear least squares optimization that
44 // attempts to minimize the reprojection error of the 3D points in the views of
45 // each camera.
46 //
47 // With a large number of points and cameras, this quickly gets to be a tough
48 // optimization problem. In many cases, bundle adjustment requires a long time
49 // to solve, and is also dependent on a good initialization (i.e. a prior on the
50 // 3D positions of all cameras and points).
51 //
52 ///////////////////////////////////////////////////////////////////////////////
53 
54 #ifndef BSFM_SFM_BUNDLE_ADJUSTER_H
55 #define BSFM_SFM_BUNDLE_ADJUSTER_H
56 
57 #include <ceres/ceres.h>
58 #include <Eigen/Core>
59 #include <vector>
60 
62 #include "view.h"
63 #include "../slam/landmark.h"
64 #include "../util/disallow_copy_and_assign.h"
65 #include "../util/types.h"
66 
67 namespace bsfm {
68 
69 using Eigen::Matrix3d;
70 using Eigen::Vector3d;
71 
73  public:
76 
77  // Solve the bundle adjustment problem, internally updating the positions of
78  // all views in 'view_indices', as well as all landmarks that they jointly
79  // observe (any landmark seen by at least 2 views).
80  bool Solve(const BundleAdjustmentOptions& options,
81  const std::vector<ViewIndex>& view_indices) const;
82 
83  private:
85 
86  // Convert a set of bundle adjustment options into Ceres options for
87  // optimization. Return whether or not the converted options are valid
88  // according to Ceres.
90  const BundleAdjustmentOptions& options,
91  ceres::Solver::Options* ceres_options) const;
92 
93 }; //\class BundleAdjuster
94 
95 } //\namespace bsfm
96 
97 #endif
bool Solve(const BundleAdjustmentOptions &options, const std::vector< ViewIndex > &view_indices) const
Definition: camera.cpp:50
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
bool ConvertOptionsToCeresOptions(const BundleAdjustmentOptions &options, ceres::Solver::Options *ceres_options) const