CreateSFMExampleData.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/slam/dataset.h>
20 
21 #include <boost/assign/std/vector.hpp>
22 
23 using namespace boost::assign;
24 using namespace std;
25 using namespace gtsam;
26 
27 /* ************************************************************************* */
28 
29 void createExampleBALFile(const string& filename, const vector<Point3>& P,
30  const Pose3& pose1, const Pose3& pose2, const Cal3Bundler& K =
31  Cal3Bundler()) {
32 
33  // Class that will gather all data
34  SfmData data;
35 
36  // Create two cameras
37  Rot3 aRb = Rot3::Yaw(M_PI_2);
38  Point3 aTb(0.1, 0, 0);
39  Pose3 identity, aPb(aRb, aTb);
40  data.cameras.push_back(SfmCamera(pose1, K));
41  data.cameras.push_back(SfmCamera(pose2, K));
42 
43  for(const Point3& p: P) {
44 
45  // Create the track
46  SfmTrack track;
47  track.p = p;
48  track.r = 1;
49  track.g = 1;
50  track.b = 1;
51 
52  // Project points in both cameras
53  for (size_t i = 0; i < 2; i++)
54  track.measurements.push_back(make_pair(i, data.cameras[i].project(p)));
55 
56  // Add track to data
57  data.tracks.push_back(track);
58  }
59 
60  writeBAL(filename, data);
61 }
62 
63 /* ************************************************************************* */
64 
66 
67  // Create two cameras poses
68  Rot3 aRb = Rot3::Yaw(M_PI_2);
69  Point3 aTb(0.1, 0, 0);
70  Pose3 pose1, pose2(aRb, aTb);
71 
72  // Create test data, we need at least 5 points
73  vector<Point3> P;
74  P += Point3(0, 0, 1), Point3(-0.1, 0, 1), Point3(0.1, 0, 1), //
75  Point3(0, 0.5, 0.5), Point3(0, -0.5, 0.5);
76 
77  // Assumes example is run in ${GTSAM_TOP}/build/examples
78  const string filename = "../../examples/data/5pointExample1.txt";
79  createExampleBALFile(filename, P, pose1, pose2);
80 }
81 
82 /* ************************************************************************* */
83 
85 
86  // Create two cameras poses
87  Rot3 aRb = Rot3::Yaw(M_PI_2);
88  Point3 aTb(10, 0, 0);
89  Pose3 pose1, pose2(aRb, aTb);
90 
91  // Create test data, we need at least 5 points
92  vector<Point3> P;
93  P += Point3(0, 0, 100), Point3(-10, 0, 100), Point3(10, 0, 100), //
94  Point3(0, 50, 50), Point3(0, -50, 50), Point3(-20, 0, 80), Point3(20, -50, 80);
95 
96  // Assumes example is run in ${GTSAM_TOP}/build/examples
97  const string filename = "../../examples/data/5pointExample2.txt";
98  Cal3Bundler K(500, 0, 0);
99  createExampleBALFile(filename, P, pose1, pose2,K);
100 }
101 
102 /* ************************************************************************* */
103 
104 int main(int argc, char* argv[]) {
107  return 0;
108 }
109 
110 /* ************************************************************************* */
111 
void create5PointExample2()
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
Define the structure for SfM data.
Definition: dataset.h:326
void createExampleBALFile(const string &filename, const vector< Point3 > &P, const Pose3 &pose1, const Pose3 &pose2, const Cal3Bundler &K=Cal3Bundler())
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
Definition: Half.h:150
void create5PointExample1()
std::vector< SfmTrack > tracks
Sparse set of points.
Definition: dataset.h:328
Define the structure for the 3D points.
Definition: dataset.h:220
int data[]
static const Pose3 pose1(Rot3(), Point3(0, 1, 0.5))
Calibrated camera for which only pose is unknown.
int main(int argc, char *argv[])
traits
Definition: chartTesting.h:28
std::vector< SfmCamera > cameras
Set of cameras.
Definition: dataset.h:327
Point3 p
3D position of the point
Definition: dataset.h:224
float * p
float b
RGB color of the 3D point.
Definition: dataset.h:225
PinholeCamera< Cal3Bundler > SfmCamera
Define the structure for the camera poses.
Definition: dataset.h:323
static const Pose3 pose2
Vector3 Point3
Definition: Point3.h:35
utility functions for loading datasets
std::vector< SfmMeasurement > measurements
The 2D image projections (id,(u,v))
Definition: dataset.h:226


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:54