timeSFMBALsmart.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #include "timeSFMBAL.h"
20 
24 #include <gtsam/geometry/Point3.h>
25 
26 using namespace std;
27 using namespace gtsam;
28 
31 
32 int main(int argc, char* argv[]) {
33  // parse options and read BAL file
34  SfmData db = preamble(argc, argv);
35 
36  // Add smart factors to graph
38  for (size_t j = 0; j < db.numberTracks(); j++) {
39  auto smartFactor = std::make_shared<SfmFactor>(gNoiseModel);
40  for (const SfmMeasurement& m : db.tracks[j].measurements) {
41  size_t i = m.first;
42  Point2 z = m.second;
43  smartFactor->add(z, C(i));
44  }
45  graph.push_back(smartFactor);
46  }
47 
49  size_t i = 0;
50  gUseSchur = false;
51  for (const SfmCamera& camera : db.cameras)
52  initial.insert(C(i++), camera);
53 
54  return optimize(db, graph, initial);
55 }
optimize
int optimize(const SfmData &db, const NonlinearFactorGraph &graph, const Values &initial, bool separateCalibration=false)
Definition: timeSFMBAL.h:64
SmartProjectionFactor.h
Smart factor on cameras (pose + calibration)
initial
Values initial
Definition: OdometryOptimize.cpp:2
Point3.h
3D Point
gtsam::SfmData
SfmData stores a bunch of SfmTracks.
Definition: SfmData.h:39
gNoiseModel
static SharedNoiseModel gNoiseModel
Definition: timeSFMBAL.h:41
gtsam::SfmData::tracks
std::vector< SfmTrack > tracks
Sparse set of points.
Definition: SfmData.h:42
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
gtsam::PinholeCamera< Cal3Bundler >
gtsam::NonlinearFactorGraph
Definition: NonlinearFactorGraph.h:55
timeSFMBAL.h
Common code for timeSFMBAL scripts.
PinholeCamera.h
Base class for all pinhole cameras.
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
gtsam::Point2
Vector2 Point2
Definition: Point2.h:32
preamble
SfmData preamble(int argc, char *argv[])
Definition: timeSFMBAL.h:44
main
int main(int argc, char *argv[])
Definition: timeSFMBALsmart.cpp:32
gtsam::SmartProjectionFactor
Definition: SmartProjectionFactor.h:44
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
gtsam
traits
Definition: SFMdata.h:40
gtsam::SfmData::cameras
std::vector< SfmCamera > cameras
Set of cameras.
Definition: SfmData.h:40
gtsam::FactorGraph::push_back
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
Definition: FactorGraph.h:147
gtsam::Values
Definition: Values.h:65
gUseSchur
static bool gUseSchur
Definition: timeSFMBAL.h:40
std
Definition: BFloat16.h:88
SfmFactor
SmartProjectionFactor< Camera > SfmFactor
Definition: timeSFMBALsmart.cpp:30
initial
Definition: testScenarioRunner.cpp:148
Camera
PinholeCamera< Cal3Bundler > Camera
Definition: timeSFMBALsmart.cpp:29
camera
static const CalibratedCamera camera(kDefaultPose)
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
gtsam::SfmData::numberTracks
size_t numberTracks() const
The number of reconstructed 3D points.
Definition: SfmData.h:74
Cal3Bundler.h
Calibration used by Bundler.
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
gtsam::SfmMeasurement
std::pair< size_t, Point2 > SfmMeasurement
A measurement with its camera index.
Definition: SfmTrack.h:32


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:09:11