36 #include <boost/smart_ptr/shared_ptr.hpp> 95 GTSAM_EXPORT std::vector<BinaryMeasurement<T>>
104 template <
typename T>
105 GTSAM_EXPORT std::vector<typename BetweenFactor<T>::shared_ptr>
108 size_t maxIndex = 0);
120 GTSAM_EXPORT boost::optional<IndexedPose>
parseVertexPose(std::istream& is,
121 const std::string& tag);
129 const std::string& tag);
136 GTSAM_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,
182 const std::string& filename);
208 const Values& estimate,
const std::string& filename);
234 return measurements.size();
238 return measurements[idx];
242 return siftIndices[idx];
250 measurements.emplace_back(idx, m);
255 template<
class ARCHIVE>
257 ar & BOOST_SERIALIZATION_NVP(p);
258 ar & BOOST_SERIALIZATION_NVP(r);
259 ar & BOOST_SERIALIZATION_NVP(g);
260 ar & BOOST_SERIALIZATION_NVP(b);
261 ar & BOOST_SERIALIZATION_NVP(measurements);
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()) {
286 SfmMeasurement otherMeasurement = sfmTrack.
measurements[idx];
288 if (measurement.first != otherMeasurement.first ||
289 !measurement.second.isApprox(otherMeasurement.second)) {
295 for (
size_t idx = 0; idx < siftIndices.size(); ++idx) {
296 SiftIndex index = siftIndices[idx];
299 if (index.first != otherIndex.first ||
300 index.second != otherIndex.second) {
309 void print(
const std::string&
s =
"")
const {
310 std::cout <<
"Track with " << measurements.size();
311 std::cout <<
" measurements of point " << p << std::endl;
330 return cameras.size();
334 return tracks.size();
350 cameras.push_back(cam);
354 friend class boost::serialization::access;
355 template<
class Archive>
357 ar & BOOST_SERIALIZATION_NVP(cameras);
358 ar & BOOST_SERIALIZATION_NVP(tracks);
374 for (
size_t i = 0;
i < number_cameras(); ++
i) {
381 for (
size_t j = 0;
j < number_tracks(); ++
j) {
382 if (!track(
j).equals(sfmData.
track(
j),
tol)) {
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;
410 GTSAM_EXPORT
bool readBundler(
const std::string& filename, SfmData &
data);
419 GTSAM_EXPORT
bool readBAL(
const std::string& filename, SfmData &data);
427 GTSAM_EXPORT SfmData
readBal(
const std::string& filename);
436 GTSAM_EXPORT
bool writeBAL(
const std::string& filename, SfmData &data);
498 size_t maxIndex = 0);
504 size_t maxIndex = 0);
507 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V41 508 inline boost::optional<IndexedPose> parseVertex(std::istream &is,
509 const std::string &tag) {
513 GTSAM_EXPORT std::map<size_t, Pose3> parse3DPoses(
const std::string &filename,
514 size_t maxIndex = 0);
516 GTSAM_EXPORT std::map<size_t, Point3>
517 parse3DLandmarks(
const std::string &filename,
size_t maxIndex = 0);
std::vector< BetweenFactor< Pose3 >::shared_ptr > BetweenFactorPose3s
void add_camera(const SfmCamera &cam)
Add a camera to SfmData.
std::pair< NonlinearFactorGraph::shared_ptr, Values::shared_ptr > GraphAndValues
void writeG2o(const NonlinearFactorGraph &graph, const Values &estimate, const string &filename)
This function writes a g2o file from NonlinearFactorGraph and a Values structure. ...
void serialize(Archive &ar, const unsigned int)
Typedefs for easier changing of types.
default: toro-style order, but covariance matrix !
bool writeBAL(const string &filename, SfmData &data)
This function writes a "Bundle Adjustment in the Large" (BAL) file from a SfmData structure...
SfmMeasurement measurement(size_t idx) const
Get the measurement (camera index, Point2) at pose index idx
Concept check for values that can be used in unit tests.
Define the structure for SfM data.
void print(const std::string &s="") const
print
std::vector< BinaryMeasurement< Unit3 >> BinaryMeasurementsUnit3
A non-templated config holding any types of Manifold-group elements.
Factor Graph consisting of non-linear factors.
friend class boost::serialization::access
KernelFunctionType
Robust kernel type to wrap around quadratic noise model.
noiseModel::Diagonal::shared_ptr model
GraphAndValues load2D(const string &filename, SharedNoiseModel model, size_t maxIndex, bool addNoise, bool smart, NoiseFormat noiseFormat, KernelFunctionType kernelFunctionType)
Pose3 gtsam2openGL(const Rot3 &R, double tx, double ty, double tz)
This function converts a GTSAM camera pose to an openGL camera pose.
bool equals(const SfmTrack &sfmTrack, double tol=1e-9) const
assert equality up to a tolerance
boost::optional< IndexedEdge > parseEdge(istream &is, const string &tag)
BetweenFactorPose3s parse3DFactors(const std::string &filename, const noiseModel::Diagonal::shared_ptr &model, size_t maxIndex)
Rot2 R(Rot2::fromAngle(0.1))
std::pair< size_t, Pose2 > IndexedPose
Return type for auxiliary functions.
BetweenFactorPose2s parse2DFactors(const std::string &filename, const noiseModel::Diagonal::shared_ptr &model, size_t maxIndex)
SfmData readBal(const string &filename)
This function parses a "Bundle Adjustment in the Large" (BAL) file and returns the data as a SfmData ...
void add_measurement(size_t idx, const gtsam::Point2 &m)
Add measurement (camera_idx, Point2) to track.
GraphAndValues load2D_robust(const string &filename, const noiseModel::Base::shared_ptr &model, size_t maxIndex)
static const Point3 pt(1.0, 2.0, 3.0)
Try to guess covariance matrix layout.
const Point3 & point3() const
Get 3D point.
NonlinearFactorGraph graph
void add_track(const SfmTrack &t)
Add a track to SfmData.
std::vector< SfmTrack > tracks
Sparse set of points.
NoiseFormat
Indicates how noise parameters are stored in file.
SiftIndex siftIndex(size_t idx) const
Get the SIFT feature index corresponding to the measurement at idx
string findExampleDataFile(const string &name)
const Point3 rgb() const
Get RGB values describing 3d point.
Base class for all pinhole cameras.
std::pair< size_t, Point2 > SfmMeasurement
A measurement with its camera index.
size_t number_tracks() const
The number of reconstructed 3D points.
std::pair< std::pair< size_t, size_t >, Pose2 > IndexedEdge
static std::map< timestep_t, std::vector< stereo_meas_t > > dataset
Information matrix, but inf_ff inf_fs inf_ss inf_rr inf_fr inf_sr.
SfmCamera camera(size_t idx) const
The camera pose at frame index idx
Define the structure for the 3D points.
std::pair< size_t, size_t > SiftIndex
Sift index for SfmTrack.
SfmTrack track(size_t idx) const
The track formed by series of landmark measurements.
std::vector< BinaryMeasurement< Pose2 > > parseMeasurements(const std::string &filename, const noiseModel::Diagonal::shared_ptr &model, size_t maxIndex)
std::pair< size_t, Point2 > IndexedLandmark
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void save2D(const NonlinearFactorGraph &graph, const Values &config, const noiseModel::Diagonal::shared_ptr model, const string &filename)
size_t number_measurements() const
Total number of measurements in this track.
string createRewrittenFileName(const string &name)
boost::shared_ptr< Diagonal > shared_ptr
Values initialCamerasEstimate(const SfmData &db)
This function creates initial values for cameras from db.
boost::shared_ptr< Base > shared_ptr
std::vector< SfmCamera > cameras
Set of cameras.
Covariance matrix C11, C12, C13, C22, C23, C33.
Information matrix I11, I12, I13, I22, I23, I33.
Pose3 openGL2gtsam(const Rot3 &R, double tx, double ty, double tz)
This function converts an openGL camera pose to an GTSAM camera pose.
std::vector< SiftIndex > siftIndices
std::vector< BetweenFactor< Pose2 >::shared_ptr > BetweenFactorPose2s
GTSAM_EXPORT std::map< size_t, T > parseVariables(const std::string &filename, size_t maxIndex=0)
Point3 p
3D position of the point
float b
RGB color of the 3D point.
void serialize(ARCHIVE &ar, const unsigned int)
void print(const std::string &s="") const
print
PinholeCamera< Cal3Bundler > SfmCamera
Define the structure for the camera poses.
Annotation for function names.
Values initialCamerasAndPointsEstimate(const SfmData &db)
This function creates initial values for cameras and points from db.
SfmTrack(float r=0, float g=0, float b=0)
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...
bool equals(const SfmData &sfmData, double tol=1e-9) const
assert equality up to a tolerance
bool readBundler(const string &filename, SfmData &data)
This function parses a bundler output file and stores the data into a SfmData structure.
static const CalibratedCamera camera(kDefaultPose)
Binary measurement represents a measurement between two keys in a graph. A binary measurement is simi...
GraphAndValues load3D(const string &filename)
Load TORO 3D Graph.
boost::optional< IndexedLandmark > parseVertexLandmark(istream &is, const string &tag)
std::vector< SfmMeasurement > measurements
The 2D image projections (id,(u,v))
Calibration used by Bundler.
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)
noiseModel::Base::shared_ptr SharedNoiseModel
boost::optional< IndexedPose > parseVertexPose(istream &is, const string &tag)
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...
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...
SfmTrack(const gtsam::Point3 &pt, float r=0, float g=0, float b=0)
size_t number_cameras() const