gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dataset.h
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 #pragma once
20 
23 #include <gtsam/geometry/Point2.h>
24 #include <gtsam/geometry/Pose3.h>
27 
28 #include <vector>
29 #include <utility> // for pair
30 #include <string>
31 
32 namespace gtsam {
33 
34 #ifndef MATLAB_MEX_FILE
35 
46 GTSAM_EXPORT std::string findExampleDataFile(const std::string& name);
47 
52 GTSAM_EXPORT std::string createRewrittenFileName(const std::string& name);
53 #endif
54 
62 };
63 
66  KernelFunctionTypeNONE, KernelFunctionTypeHUBER, KernelFunctionTypeTUKEY
67 };
68 
70 typedef std::pair<NonlinearFactorGraph::shared_ptr, Values::shared_ptr> GraphAndValues;
71 
79 GTSAM_EXPORT GraphAndValues load2D(
80  std::pair<std::string, SharedNoiseModel> dataset, int maxID = 0,
81  bool addNoise = false,
82  bool smart = true, //
83  NoiseFormat noiseFormat = NoiseFormatAUTO,
84  KernelFunctionType kernelFunctionType = KernelFunctionTypeNONE);
85 
97 GTSAM_EXPORT GraphAndValues load2D(const std::string& filename,
98  SharedNoiseModel model = SharedNoiseModel(), Key maxID = 0, bool addNoise =
99  false, bool smart = true, NoiseFormat noiseFormat = NoiseFormatAUTO, //
100  KernelFunctionType kernelFunctionType = KernelFunctionTypeNONE);
101 
103 GTSAM_EXPORT GraphAndValues load2D_robust(const std::string& filename,
104  noiseModel::Base::shared_ptr& model, int maxID = 0);
105 
107 GTSAM_EXPORT void save2D(const NonlinearFactorGraph& graph,
108  const Values& config, const noiseModel::Diagonal::shared_ptr model,
109  const std::string& filename);
110 
119 GTSAM_EXPORT GraphAndValues readG2o(const std::string& g2oFile, const bool is3D = false,
120  KernelFunctionType kernelFunctionType = KernelFunctionTypeNONE);
121 
129 GTSAM_EXPORT void writeG2o(const NonlinearFactorGraph& graph,
130  const Values& estimate, const std::string& filename);
131 
135 GTSAM_EXPORT GraphAndValues load3D(const std::string& filename);
136 
138 typedef std::pair<size_t, Point2> SfM_Measurement;
139 
141 struct SfM_Track {
143  float r, g, b;
144  std::vector<SfM_Measurement> measurements;
145  size_t number_measurements() const {
146  return measurements.size();
147  }
148 };
149 
152 
154 struct SfM_data {
155  std::vector<SfM_Camera> cameras;
156  std::vector<SfM_Track> tracks;
157  size_t number_cameras() const {
158  return cameras.size();
159  }
160  size_t number_tracks() const {
161  return tracks.size();
162  }
163 };
164 
172 GTSAM_EXPORT bool readBundler(const std::string& filename, SfM_data &data);
173 
181 GTSAM_EXPORT bool readBAL(const std::string& filename, SfM_data &data);
182 
190 GTSAM_EXPORT bool writeBAL(const std::string& filename, SfM_data &data);
191 
203 GTSAM_EXPORT bool writeBALfromValues(const std::string& filename,
204  const SfM_data &data, Values& values);
205 
214 GTSAM_EXPORT Pose3 openGL2gtsam(const Rot3& R, double tx, double ty, double tz);
215 
224 GTSAM_EXPORT Pose3 gtsam2openGL(const Rot3& R, double tx, double ty, double tz);
225 
231 GTSAM_EXPORT Pose3 gtsam2openGL(const Pose3& PoseGTSAM);
232 
238 GTSAM_EXPORT Values initialCamerasEstimate(const SfM_data& db);
239 
245 GTSAM_EXPORT Values initialCamerasAndPointsEstimate(const SfM_data& db);
246 
247 } // namespace gtsam
Define the structure for SfM data.
Definition: dataset.h:154
NoiseFormat
Indicates how noise parameters are stored in file.
Definition: dataset.h:56
size_t number_cameras() const
The number of camera poses.
Definition: dataset.h:157
PinholeCamera< Cal3Bundler > SfM_Camera
Define the structure for the camera poses.
Definition: dataset.h:151
GraphAndValues load3D(const string &filename)
Load TORO 3D Graph.
Definition: dataset.cpp:479
bool writeBALfromValues(const string &filename, const SfM_data &data, Values &values)
This function writes a "Bundle Adjustment in the Large" (BAL) file from a SfM_data structure and a va...
Definition: dataset.cpp:816
string findExampleDataFile(const string &name)
Find the full path to an example dataset distributed with gtsam.
Definition: dataset.cpp:42
std::vector< SfM_Track > tracks
Sparse set of points.
Definition: dataset.h:156
Point3 p
3D position of the point
Definition: dataset.h:142
bool writeBAL(const string &filename, SfM_data &data)
This function writes a "Bundle Adjustment in the Large" (BAL) file from a SfM_data structure...
Definition: dataset.cpp:745
Information matrix I11, I12, I13, I22, I23, I33.
Definition: dataset.h:57
std::vector< SfM_Measurement > measurements
The 2D image projections (id,(u,v))
Definition: dataset.h:144
Values initialCamerasEstimate(const SfM_data &db)
This function creates initial values for cameras from db.
Definition: dataset.cpp:876
default: toro-style order, but covariance matrix !
Definition: dataset.h:59
2D Point
Factor Graph Constsiting of non-linear factors.
Base class for all pinhole cameras.
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:75
void save2D(const NonlinearFactorGraph &graph, const Values &config, const noiseModel::Diagonal::shared_ptr model, const string &filename)
save 2d graph
Definition: dataset.cpp:346
size_t number_tracks() const
The number of reconstructed 3D points.
Definition: dataset.h:160
Definition: PinholeCamera.h:40
Try to guess covariance matrix layout.
Definition: dataset.h:61
A non-linear factor graph is a graph of non-Gaussian, i.e.
Definition: NonlinearFactorGraph.h:69
float b
RGB color of the 3D point.
Definition: dataset.h:143
Pose3 openGL2gtsam(const Rot3 &R, double tx, double ty, double tz)
This function converts an openGL camera pose to an GTSAM camera pose.
Definition: dataset.cpp:579
GraphAndValues load2D_robust(const string &filename, noiseModel::Base::shared_ptr &model, int maxID)
Definition: dataset.cpp:340
Calibration used by Bundler.
bool readBAL(const string &filename, SfM_data &data)
This function parses a "Bundle Adjustment in the Large" (BAL) file and stores the data into a SfM_dat...
Definition: dataset.cpp:685
size_t Key
Integer nonlinear key type.
Definition: types.h:59
Define the structure for the 3D points.
Definition: dataset.h:141
std::vector< SfM_Camera > cameras
Set of cameras.
Definition: dataset.h:155
3D Pose
KernelFunctionType
Robust kernel type to wrap around quadratic noise model.
Definition: dataset.h:65
Information matrix, but inf_ff inf_fs inf_ss inf_rr inf_fr inf_sr.
Definition: dataset.h:58
Covariance matrix C11, C12, C13, C22, C23, C33.
Definition: dataset.h:60
std::pair< NonlinearFactorGraph::shared_ptr, Values::shared_ptr > GraphAndValues
Return type for load functions.
Definition: dataset.h:70
Values initialCamerasAndPointsEstimate(const SfM_data &db)
This function creates initial values for cameras and points from db.
Definition: dataset.cpp:884
string createRewrittenFileName(const string &name)
Creates a temporary file name that needs to be ignored in .gitingnore for checking read-write opratio...
Definition: dataset.cpp:73
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:884
GraphAndValues readG2o(const string &g2oFile, const bool is3D, KernelFunctionType kernelFunctionType)
This function parses a g2o file and stores the measurements into a NonlinearFactorGraph and the initi...
Definition: dataset.cpp:378
Definition: Point3.h:39
void writeG2o(const NonlinearFactorGraph &graph, const Values &estimate, const string &filename)
This function writes a g2o file from NonlinearFactorGraph and a Values structure. ...
Definition: dataset.cpp:393
Pose3 gtsam2openGL(const Rot3 &R, double tx, double ty, double tz)
This function converts a GTSAM camera pose to an openGL camera pose.
Definition: dataset.cpp:588
bool readBundler(const string &filename, SfM_data &data)
This function parses a bundler output file and stores the data into a SfM_data structure.
Definition: dataset.cpp:602
std::pair< size_t, Point2 > SfM_Measurement
A measurement with its camera index.
Definition: dataset.h:138