36#include <boost/smart_ptr/shared_ptr.hpp>
75 KernelFunctionTypeNONE, KernelFunctionTypeHUBER, KernelFunctionTypeTUKEY
95GTSAM_EXPORT std::vector<BinaryMeasurement<T>>
96parseMeasurements(
const std::string &filename,
97 const noiseModel::Diagonal::shared_ptr &model =
nullptr,
105GTSAM_EXPORT std::vector<typename BetweenFactor<T>::shared_ptr>
107 const noiseModel::Diagonal::shared_ptr &model =
nullptr,
108 size_t maxIndex = 0);
112typedef std::pair<size_t, Point2> IndexedLandmark;
113typedef std::pair<std::pair<size_t, size_t>,
Pose2> IndexedEdge;
120GTSAM_EXPORT boost::optional<IndexedPose>
parseVertexPose(std::istream& is,
121 const std::string& tag);
129 const std::string& tag);
136GTSAM_EXPORT boost::optional<IndexedEdge>
parseEdge(std::istream& is,
137 const std::string& tag);
143 std::pair<NonlinearFactorGraph::shared_ptr, Values::shared_ptr>;
153 std::pair<std::string, SharedNoiseModel> dataset,
size_t maxIndex = 0,
154 bool addNoise =
false,
177 const noiseModel::Base::shared_ptr& model,
size_t maxIndex = 0);
181 const Values& config,
const noiseModel::Diagonal::shared_ptr model,
182 const std::string& filename);
208 const Values& estimate,
const std::string& filename);
221 SfmTrack(
float r = 0,
float g = 0,
float b = 0):
p(0,0,0), r(r), g(g),
b(
b) {}
227 std::vector<SiftIndex> siftIndices;
242 return siftIndices[idx];
255 template<
class ARCHIVE>
256 void serialize(ARCHIVE & ar,
const unsigned int ) {
257 ar & BOOST_SERIALIZATION_NVP(
p);
258 ar & BOOST_SERIALIZATION_NVP(r);
259 ar & BOOST_SERIALIZATION_NVP(g);
260 ar & BOOST_SERIALIZATION_NVP(
b);
262 ar & BOOST_SERIALIZATION_NVP(siftIndices);
268 if (!
p.isApprox(sfmTrack.
p)) {
273 if (r!=sfmTrack.r || g!=sfmTrack.g ||
b!=sfmTrack.
b) {
279 siftIndices.size() != sfmTrack.siftIndices.size()) {
289 !
measurement.second.isApprox(otherMeasurement.second)) {
295 for (
size_t idx = 0; idx < siftIndices.size(); ++idx) {
297 SiftIndex otherIndex = sfmTrack.siftIndices[idx];
299 if (index.first != otherIndex.first ||
300 index.second != otherIndex.second) {
309 void print(
const std::string& s =
"")
const {
311 std::cout <<
" measurements of point " <<
p << std::endl;
329 size_t number_cameras()
const {
355 template<
class Archive>
356 void serialize(Archive & ar,
const unsigned int ) {
357 ar & BOOST_SERIALIZATION_NVP(
cameras);
358 ar & BOOST_SERIALIZATION_NVP(
tracks);
368 if (number_cameras() != sfmData.number_cameras() ||
374 for (
size_t i = 0; i < number_cameras(); ++i) {
391 void print(
const std::string& s =
"")
const {
392 std::cout <<
"Number of cameras = " << number_cameras() << std::endl;
393 std::cout <<
"Number of tracks = " <<
number_tracks() << std::endl;
419GTSAM_EXPORT
bool readBAL(
const std::string& filename,
SfmData &data);
494using BetweenFactorPose2s = std::vector<BetweenFactor<Pose2>::shared_ptr>;
495GTSAM_EXPORT BetweenFactorPose2s
496parse2DFactors(
const std::string &filename,
497 const noiseModel::Diagonal::shared_ptr &model =
nullptr,
498 size_t maxIndex = 0);
500using BetweenFactorPose3s = std::vector<BetweenFactor<Pose3>::shared_ptr>;
501GTSAM_EXPORT BetweenFactorPose3s
502parse3DFactors(
const std::string &filename,
503 const noiseModel::Diagonal::shared_ptr &model =
nullptr,
504 size_t maxIndex = 0);
506using BinaryMeasurementsUnit3 = std::vector<BinaryMeasurement<Unit3>>;
507#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V41
508inline boost::optional<IndexedPose> parseVertex(std::istream &is,
509 const std::string &tag) {
513GTSAM_EXPORT std::map<size_t, Pose3> parse3DPoses(
const std::string &filename,
514 size_t maxIndex = 0);
516GTSAM_EXPORT std::map<size_t, Point3>
517parse3DLandmarks(
const std::string &filename,
size_t maxIndex = 0);
Typedefs for easier changing of types.
Concept check for values that can be used in unit tests.
Base class for all pinhole cameras.
Calibration used by Bundler.
A non-templated config holding any types of Manifold-group elements.
Factor Graph consisting of non-linear factors.
Binary measurement represents a measurement between two keys in a graph. A binary measurement is simi...
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::pair< size_t, size_t > SiftIndex
Sift index for SfmTrack.
Definition: dataset.h:217
bool readBundler(const string &filename, SfmData &data)
This function parses a bundler output file and stores the data into a SfmData structure.
Definition: dataset.cpp:986
GraphAndValues load2D(const string &filename, SharedNoiseModel model, size_t maxIndex, bool addNoise, bool smart, NoiseFormat noiseFormat, KernelFunctionType kernelFunctionType)
Load TORO/G2O style graph files.
Definition: dataset.cpp:500
GTSAM_EXPORT std::map< size_t, T > parseVariables(const std::string &filename, size_t maxIndex=0)
Parse variables in a line-based text format (like g2o) into a map.
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:630
std::pair< size_t, Pose2 > IndexedPose
Return type for auxiliary functions.
Definition: dataset.h:111
Vector2 Point2
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point2 to Vector2...
Definition: Point2.h:27
SfmData readBal(const string &filename)
This function parses a "Bundle Adjustment in the Large" (BAL) file and returns the data as a SfmData ...
Definition: dataset.cpp:1133
bool writeBALfromValues(const string &filename, const SfmData &data, Values &values)
This function writes a "Bundle Adjustment in the Large" (BAL) file from a SfmData structure and a val...
Definition: dataset.cpp:1216
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:615
GTSAM_EXPORT std::vector< typename BetweenFactor< T >::shared_ptr > parseFactors(const std::string &filename, const noiseModel::Diagonal::shared_ptr &model=nullptr, size_t maxIndex=0)
Parse BetweenFactors in a line-based text format (like g2o) into a vector of shared pointers.
KernelFunctionType
Robust kernel type to wrap around quadratic noise model.
Definition: dataset.h:74
NoiseFormat
Indicates how noise parameters are stored in file.
Definition: dataset.h:65
@ NoiseFormatGRAPH
default: toro-style order, but covariance matrix !
Definition: dataset.h:68
@ NoiseFormatAUTO
Try to guess covariance matrix layout.
Definition: dataset.h:70
@ NoiseFormatTORO
Information matrix, but inf_ff inf_fs inf_ss inf_rr inf_fr inf_sr.
Definition: dataset.h:67
@ NoiseFormatCOV
Covariance matrix C11, C12, C13, C22, C23, C33.
Definition: dataset.h:69
@ NoiseFormatG2O
Information matrix I11, I12, I13, I22, I23, I33.
Definition: dataset.h:66
boost::optional< IndexedLandmark > parseVertexLandmark(istream &is, const string &tag)
Parse G2O landmark vertex "id x y".
Definition: dataset.cpp:188
std::pair< size_t, Point2 > SfmMeasurement
A measurement with its camera index.
Definition: dataset.h:214
Vector3 Point3
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point3 to Vector3...
Definition: Point3.h:35
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:972
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:736
Values initialCamerasAndPointsEstimate(const SfmData &db)
This function creates initial values for cameras and points from db.
Definition: dataset.cpp:1284
GraphAndValues load2D_robust(const string &filename, const noiseModel::Base::shared_ptr &model, size_t maxIndex)
Definition: dataset.cpp:575
boost::optional< IndexedEdge > parseEdge(istream &is, const string &tag)
Parse TORO/G2O edge "id1 id2 x y yaw".
Definition: dataset.cpp:294
std::pair< NonlinearFactorGraph::shared_ptr, Values::shared_ptr > GraphAndValues
Return type for load functions, which return a graph and initial values.
Definition: dataset.h:143
boost::optional< IndexedPose > parseVertexPose(istream &is, const string &tag)
Parse TORO/G2O vertex "id x y yaw".
Definition: dataset.cpp:168
GraphAndValues load3D(const string &filename)
Load TORO 3D Graph.
Definition: dataset.cpp:924
PinholeCamera< Cal3Bundler > SfmCamera
Define the structure for the camera poses.
Definition: dataset.h:323
void save2D(const NonlinearFactorGraph &graph, const Values &config, const noiseModel::Diagonal::shared_ptr model, const string &filename)
save 2d graph
Definition: dataset.cpp:582
Values initialCamerasEstimate(const SfmData &db)
This function creates initial values for cameras from db.
Definition: dataset.cpp:1276
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:100
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:963
bool writeBAL(const string &filename, SfmData &data)
This function writes a "Bundle Adjustment in the Large" (BAL) file from a SfmData structure.
Definition: dataset.cpp:1140
string findExampleDataFile(const string &name)
Find the full path to an example dataset distributed with gtsam.
Definition: dataset.cpp:65
bool readBAL(const string &filename, SfmData &data)
This function parses a "Bundle Adjustment in the Large" (BAL) file and stores the data into a SfmData...
Definition: dataset.cpp:1073
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:151
Definition: PinholeCamera.h:33
bool equals(const Base &camera, double tol=1e-9) const
assert equality up to a tolerance
Definition: PinholeCamera.h:145
A non-linear factor graph is a graph of non-Gaussian, i.e.
Definition: NonlinearFactorGraph.h:78
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:63
Define the structure for the 3D points.
Definition: dataset.h:220
std::vector< SfmMeasurement > measurements
The 2D image projections (id,(u,v))
Definition: dataset.h:226
void print(const std::string &s="") const
print
Definition: dataset.h:309
float b
RGB color of the 3D point.
Definition: dataset.h:225
void add_measurement(size_t idx, const gtsam::Point2 &m)
Add measurement (camera_idx, Point2) to track.
Definition: dataset.h:249
size_t number_measurements() const
Total number of measurements in this track.
Definition: dataset.h:233
SfmMeasurement measurement(size_t idx) const
Get the measurement (camera index, Point2) at pose index idx
Definition: dataset.h:237
const Point3 rgb() const
Get RGB values describing 3d point.
Definition: dataset.h:230
bool equals(const SfmTrack &sfmTrack, double tol=1e-9) const
assert equality up to a tolerance
Definition: dataset.h:266
SiftIndex siftIndex(size_t idx) const
Get the SIFT feature index corresponding to the measurement at idx
Definition: dataset.h:241
friend class boost::serialization::access
Serialization function.
Definition: dataset.h:254
const Point3 & point3() const
Get 3D point.
Definition: dataset.h:245
Point3 p
3D position of the point
Definition: dataset.h:224
Define the structure for SfM data.
Definition: dataset.h:326
SfmCamera camera(size_t idx) const
The camera pose at frame index idx
Definition: dataset.h:337
void add_camera(const SfmCamera &cam)
Add a camera to SfmData.
Definition: dataset.h:349
void print(const std::string &s="") const
print
Definition: dataset.h:391
size_t number_tracks() const
The number of reconstructed 3D points.
Definition: dataset.h:333
friend class boost::serialization::access
Serialization function.
Definition: dataset.h:354
std::vector< SfmCamera > cameras
Set of cameras.
Definition: dataset.h:327
void add_track(const SfmTrack &t)
Add a track to SfmData.
Definition: dataset.h:345
bool equals(const SfmData &sfmData, double tol=1e-9) const
assert equality up to a tolerance
Definition: dataset.h:366
std::vector< SfmTrack > tracks
Sparse set of points.
Definition: dataset.h:328
SfmTrack track(size_t idx) const
The track formed by series of landmark measurements.
Definition: dataset.h:341
Convenience functions for serializing data structures via boost.serialization.