Loading...
Searching...
No Matches
SfmData.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/geometry/Cal3Bundler.h>
#include <gtsam/geometry/PinholeCamera.h>
#include <gtsam/nonlinear/NonlinearFactorGraph.h>
#include <gtsam/nonlinear/Values.h>
#include <gtsam/sfm/SfmTrack.h>
#include <string>
#include <vector>
namespace gtsam {
typedef PinholeCamera<Cal3Bundler> SfmCamera;
struct GTSAM_EXPORT SfmData {
std::vector<SfmCamera> cameras;
std::vector<SfmTrack> tracks;
static SfmData FromBundlerFile(const std::string& filename);
static SfmData FromBalFile(const std::string& filename);
void addTrack(const SfmTrack& t) { tracks.push_back(t); }
void addCamera(const SfmCamera& cam) { cameras.push_back(cam); }
size_t numberTracks() const { return tracks.size(); }
size_t numberCameras() const { return cameras.size(); }
const SfmTrack& track(size_t idx) const { return tracks[idx]; }
const SfmCamera& camera(size_t idx) const { return cameras[idx]; }
const std::vector<SfmCamera>& cameraList() const { return cameras; }
const std::vector<SfmTrack>& trackList() const { return tracks; }
NonlinearFactorGraph generalSfmFactors(
const SharedNoiseModel& model = noiseModel::Isotropic::Sigma(2,
1.0)) const;
NonlinearFactorGraph sfmFactorGraph(
const SharedNoiseModel& model = noiseModel::Isotropic::Sigma(2, 1.0),
boost::optional<size_t> fixedCamera = 0,
boost::optional<size_t> fixedPoint = 0) const;
void print(const std::string& s = "") const;
bool equals(const SfmData& sfmData, double tol = 1e-9) const;
#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V42
void GTSAM_DEPRECATED add_track(const SfmTrack& t) { tracks.push_back(t); }
void GTSAM_DEPRECATED add_camera(const SfmCamera& cam) {
cameras.push_back(cam);
}
size_t GTSAM_DEPRECATED number_tracks() const { return tracks.size(); }
size_t GTSAM_DEPRECATED number_cameras() const { return cameras.size(); }
#endif
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int /*version*/) {
ar& BOOST_SERIALIZATION_NVP(cameras);
ar& BOOST_SERIALIZATION_NVP(tracks);
}
};
template <>
struct traits<SfmData> : public Testable<SfmData> {};
#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V42
GTSAM_EXPORT bool GTSAM_DEPRECATED readBundler(const std::string& filename,
SfmData& data);
GTSAM_EXPORT bool GTSAM_DEPRECATED readBAL(const std::string& filename,
SfmData& data);
#endif
GTSAM_EXPORT SfmData readBal(const std::string& filename);
GTSAM_EXPORT bool writeBAL(const std::string& filename, const SfmData& data);
GTSAM_EXPORT bool writeBALfromValues(const std::string& filename,
const SfmData& data, const Values& values);
GTSAM_EXPORT Pose3 openGL2gtsam(const Rot3& R, double tx, double ty, double tz);
GTSAM_EXPORT Pose3 gtsam2openGL(const Rot3& R, double tx, double ty, double tz);
GTSAM_EXPORT Pose3 gtsam2openGL(const Pose3& PoseGTSAM);
GTSAM_EXPORT Values initialCamerasEstimate(const SfmData& db);
GTSAM_EXPORT Values initialCamerasAndPointsEstimate(const SfmData& db);
} // namespace gtsam
PinholeCamera.h
Base class for all pinhole cameras.
Cal3Bundler.h
Calibration used by Bundler.
NonlinearFactorGraph.h
Factor Graph consisting of non-linear factors.
Values.h
A non-templated config holding any types of Manifold-group elements.
SfmTrack.h
A simple data structure for a track in Structure from Motion.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::writeBAL
bool writeBAL(const std::string &filename, const SfmData &data)
This function writes a "Bundle Adjustment in the Large" (BAL) file from a SfmData structure.
Definition SfmData.cpp:249
gtsam::writeBALfromValues
bool writeBALfromValues(const std::string &filename, const SfmData &data, const Values &values)
This function writes a "Bundle Adjustment in the Large" (BAL) file from a SfmData structure and a val...
Definition SfmData.cpp:349
gtsam::readBal
SfmData readBal(const std::string &filename)
This function parses a "Bundle Adjustment in the Large" (BAL) file and returns the data as a SfmData ...
Definition SfmData.cpp:344
gtsam::gtsam2openGL
Pose3 gtsam2openGL(const Rot3 &R, double tx, double ty, double tz)
This function converts a GTSAM camera pose to an openGL camera pose.
Definition SfmData.cpp:88
gtsam::initialCamerasAndPointsEstimate
Values initialCamerasAndPointsEstimate(const SfmData &db)
This function creates initial values for cameras and points from db.
Definition SfmData.cpp:449
gtsam::SfmCamera
PinholeCamera< Cal3Bundler > SfmCamera
Define the structure for the camera poses.
Definition SfmData.h:33
gtsam::initialCamerasEstimate
Values initialCamerasEstimate(const SfmData &db)
This function creates initial values for cameras from db.
Definition SfmData.cpp:441
gtsam::openGL2gtsam
Pose3 openGL2gtsam(const Rot3 &R, double tx, double ty, double tz)
This function converts an openGL camera pose to an GTSAM camera pose.
Definition SfmData.cpp:79
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::PinholeCamera
A pinhole camera class that has a Pose3 and a Calibration.
Definition PinholeCamera.h:33
gtsam::Pose3
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:37
gtsam::Rot3
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition Rot3.h:58
gtsam::Values
A non-templated config holding any types of Manifold-group elements.
Definition Values.h:65
gtsam::SfmData
SfmData stores a bunch of SfmTracks.
Definition SfmData.h:39
gtsam::SfmData::FromBundlerFile
static SfmData FromBundlerFile(const std::string &filename)
Parses a bundler output file and return result as SfmData instance.
Definition SfmData.cpp:102
gtsam::SfmData::cameraList
const std::vector< SfmCamera > & cameraList() const
Getters.
Definition SfmData.h:86
gtsam::SfmData::addCamera
void addCamera(const SfmCamera &cam)
Add a camera to SfmData.
Definition SfmData.h:71
gtsam::SfmData::numberCameras
size_t numberCameras() const
The number of cameras.
Definition SfmData.h:77
gtsam::SfmData::numberTracks
size_t numberTracks() const
The number of reconstructed 3D points.
Definition SfmData.h:74
gtsam::SfmData::track
const SfmTrack & track(size_t idx) const
The track formed by series of landmark measurements.
Definition SfmData.h:80
gtsam::SfmData::addTrack
void addTrack(const SfmTrack &t)
Add a track to SfmData.
Definition SfmData.h:68
gtsam::SfmData::camera
const SfmCamera & camera(size_t idx) const
The camera pose at frame index idx.
Definition SfmData.h:83
gtsam::SfmData::cameras
std::vector< SfmCamera > cameras
Set of cameras.
Definition SfmData.h:40
gtsam::SfmData::FromBalFile
static SfmData FromBalFile(const std::string &filename)
Parse a "Bundle Adjustment in the Large" (BAL) file and return result as SfmData instance.
Definition SfmData.cpp:189
gtsam::SfmData::tracks
std::vector< SfmTrack > tracks
Sparse set of points.
Definition SfmData.h:42
gtsam::SfmTrack
Definition SfmTrack.h:126