testGeneralSFMFactorB.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 
18 #include <gtsam/sfm/SfmData.h>
19 #include <gtsam/slam/dataset.h>
21 #include <gtsam/geometry/Point3.h>
25 #include <gtsam/nonlinear/Values.h>
26 #include <gtsam/inference/Symbol.h>
28 
29 #include <CppUnitLite/Failure.h>
30 #include <CppUnitLite/Test.h>
32 #include <CppUnitLite/TestResult.h>
33 #include <stddef.h>
34 #include <stdexcept>
35 #include <string>
36 
37 using namespace std;
38 using namespace gtsam;
39 
42 
43 /* ************************************************************************* */
45  string filename = findExampleDataFile("dubrovnik-3-7-pre");
46  SfmData db = SfmData::FromBalFile(filename);
47 
48  SharedNoiseModel unit2 = noiseModel::Unit::Create(2);
50 
51  for (size_t j = 0; j < db.numberTracks(); j++) {
52  for (const SfmMeasurement& m: db.tracks[j].measurements)
53  graph.emplace_shared<sfmFactor>(m.second, unit2, m.first, P(j));
54  }
55 
57 
59 
60  Values actual = lm.optimize();
61  double actualError = graph.error(actual);
62  EXPECT_DOUBLES_EQUAL(0.0199833, actualError, 1e-5);
63 }
64 
65 /* ************************************************************************* */
66 int main() {
67  TestResult tr;
68  return TestRegistry::runAllTests(tr);
69 }
70 /* ************************************************************************* */
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
gtsam::NonlinearOptimizer::optimize
virtual const Values & optimize()
Definition: NonlinearOptimizer.h:98
gtsam::initialCamerasAndPointsEstimate
Values initialCamerasAndPointsEstimate(const SfmData &db)
This function creates initial values for cameras and points from db.
Definition: SfmData.cpp:430
TestResult.h
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
LevenbergMarquardtOptimizer.h
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
NonlinearOptimizer.h
Base class and parameters for nonlinear optimization algorithms.
GeneralSFMFactor.h
a general SFM factor with an unknown calibration
Point3.h
3D Point
gtsam::SfmData
SfmData stores a bunch of SfmTracks.
Definition: SfmData.h:39
gtsam::NonlinearFactorGraph::error
double error(const Values &values) const
Definition: NonlinearFactorGraph.cpp:170
gtsam::SfmData::tracks
std::vector< SfmTrack > tracks
Sparse set of points.
Definition: SfmData.h:42
dataset.h
utility functions for loading datasets
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
sfmFactor
GeneralSFMFactor< PinholeCamera< Cal3Bundler >, Point3 > sfmFactor
Definition: testGeneralSFMFactorB.cpp:40
relicense.filename
filename
Definition: relicense.py:57
gtsam::PinholeCamera
Definition: PinholeCamera.h:33
gtsam::NonlinearFactorGraph
Definition: NonlinearFactorGraph.h:55
gtsam::LevenbergMarquardtOptimizer
Definition: LevenbergMarquardtOptimizer.h:35
Symbol.h
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
gtsam::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:762
TestRegistry.h
EXPECT_DOUBLES_EQUAL
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
Definition: Test.h:161
TestResult
Definition: TestResult.h:26
SfmData.h
Data structure for dealing with Structure from Motion data.
Test.h
main
int main()
Definition: testGeneralSFMFactorB.cpp:66
gtsam
traits
Definition: SFMdata.h:40
NoiseModel.h
NonlinearFactorGraph.h
Factor Graph consisting of non-linear factors.
gtsam::Values
Definition: Values.h:65
std
Definition: BFloat16.h:88
gtsam::GeneralSFMFactor
Definition: GeneralSFMFactor.h:59
P
static double P[]
Definition: ellpe.c:68
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
initial
Definition: testScenarioRunner.cpp:148
gtsam::findExampleDataFile
GTSAM_EXPORT std::string findExampleDataFile(const std::string &name)
Definition: dataset.cpp:70
Failure.h
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
TEST
TEST(PinholeCamera, BAL)
Definition: testGeneralSFMFactorB.cpp:44
Values.h
A non-templated config holding any types of Manifold-group elements.
gtsam::FactorGraph::emplace_shared
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
Definition: FactorGraph.h:153
gtsam::SfmMeasurement
std::pair< size_t, Point2 > SfmMeasurement
A measurement with its camera index.
Definition: SfmTrack.h:32


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:16:25