44 #include <boost/assign/list_inserter.hpp> 45 #include <boost/filesystem/operations.hpp> 46 #include <boost/filesystem/path.hpp> 47 #include <boost/optional.hpp> 55 namespace fs = boost::filesystem;
60 #define LINESIZE 81920 67 vector<string> rootsToSearch;
70 rootsToSearch.push_back(GTSAM_SOURCE_TREE_DATASET_DIR);
71 rootsToSearch.push_back(GTSAM_INSTALLED_DATASET_DIR);
74 vector<string> namesToSearch;
75 namesToSearch.push_back(name);
76 namesToSearch.push_back(name +
".graph");
77 namesToSearch.push_back(name +
".txt");
78 namesToSearch.push_back(name +
".out");
79 namesToSearch.push_back(name +
".xml");
80 namesToSearch.push_back(name +
".g2o");
83 for (
const fs::path
root : rootsToSearch) {
84 for (
const fs::path name : namesToSearch) {
85 if (fs::is_regular_file(
root / name))
86 return (
root / name).string();
91 throw invalid_argument(
92 "gtsam::findExampleDataFile could not find a matching " 93 "file in\n" GTSAM_SOURCE_TREE_DATASET_DIR
94 " or\n" GTSAM_INSTALLED_DATASET_DIR
" named\n" +
95 name +
", " + name +
".g2o, " +
", " + name +
".graph, or " + name +
102 if (!exists(fs::path(name))) {
103 throw invalid_argument(
104 "gtsam::createRewrittenFileName could not find a matching file in\n" +
109 fs::path newpath = fs::path(p.parent_path().string()) /
110 fs::path(p.stem().string() +
"-rewritten.txt");
112 return newpath.string();
117 template <
typename T>
119 std::function<boost::optional<T>(istream &is,
const string &tag)>;
124 template <
typename T>
126 ifstream is(filename.c_str());
128 throw invalid_argument(
"parse: can not find file " + filename);
138 template <
typename T>
143 if (
auto t =
parse(is, tag)) {
144 if (!maxIndex ||
t->first <= maxIndex)
155 template <
typename T>
159 if (
auto t =
parse(is, tag))
160 result.push_back(*
t);
169 if ((tag ==
"VERTEX2") || (tag ==
"VERTEX_SE2") || (tag ==
"VERTEX")) {
172 if (!(is >>
id >> x >> y >> yaw)) {
173 throw std::runtime_error(
"parseVertexPose encountered malformed line");
190 if (tag ==
"VERTEX_XY") {
193 if (!(is >>
id >> x >> y)) {
194 throw std::runtime_error(
195 "parseVertexLandmark encountered malformed line");
216 if (
v(0) != 0.0 &&
v(1) == 0.0 &&
v(2) != 0.0 &&
217 v(3) != 0.0 &&
v(4) == 0.0 &&
v(5) == 0.0) {
219 }
else if (
v(0) != 0.0 &&
v(1) == 0.0 &&
v(2) == 0.0 &&
220 v(3) != 0.0 &&
v(4) == 0.0 &&
v(5) != 0.0) {
223 throw std::invalid_argument(
224 "load2D: unrecognized covariance matrix format in dataset file. " 225 "Please specify the noise format.");
231 switch (noiseFormat) {
237 if (
v(0) == 0.0 ||
v(3) == 0.0 ||
v(5) == 0.0)
239 "load2D::readNoiseModel looks like this is not G2O matrix order");
240 M <<
v(0),
v(1),
v(2),
v(1),
v(3),
v(4),
v(2),
v(4),
v(5);
249 if (
v(0) == 0.0 ||
v(2) == 0.0 ||
v(3) == 0.0)
250 throw invalid_argument(
251 "load2D::readNoiseModel looks like this is not TORO matrix order");
252 M <<
v(0),
v(1),
v(4),
v(1),
v(2),
v(5),
v(4),
v(5),
v(3);
255 throw runtime_error(
"load2D: invalid noise format");
261 switch (noiseFormat) {
265 model = noiseModel::Gaussian::Information(M, smart);
270 model = noiseModel::Gaussian::Covariance(M, smart);
273 throw invalid_argument(
"load2D: invalid noise format");
276 switch (kernelFunctionType) {
281 return noiseModel::Robust::Create(
282 noiseModel::mEstimator::Huber::Create(1.345), model);
285 return noiseModel::Robust::Create(
286 noiseModel::mEstimator::Tukey::Create(4.6851), model);
289 throw invalid_argument(
"load2D: invalid kernel function type");
294 boost::optional<IndexedEdge>
parseEdge(istream &is,
const string &tag) {
295 if ((tag ==
"EDGE2") || (tag ==
"EDGE") || (tag ==
"EDGE_SE2") ||
296 (tag ==
"ODOMETRY")) {
300 if (!(is >> id1 >> id2 >> x >> y >> yaw)) {
301 throw std::runtime_error(
"parseEdge encountered malformed line");
321 typename boost::optional<typename BetweenFactor<T>::shared_ptr>
324 return boost::make_shared<BetweenFactor<T>>(
325 m->key1(),
m->key2(),
m->measured(),
m->noiseModel());
347 boost::optional<BinaryMeasurement<Pose2>>
operator()(istream &is,
355 is >>
v(0) >>
v(1) >>
v(2) >>
v(3) >>
v(4) >>
v(5);
359 tie(id1, id2) = edge->first;
360 if (maxIndex && (id1 > maxIndex || id2 > maxIndex))
366 pose = pose.
retract(sampler->sample());
372 model ? model : modelFromFile);
381 throw invalid_argument(
"gtsam::load: invalid noise model for adding noise" 382 "(current version assumes diagonal noise model)!");
383 return boost::shared_ptr<Sampler>(
new Sampler(noise));
389 std::vector<BinaryMeasurement<Pose2>>
396 return parseToVector<BinaryMeasurement<Pose2>>(
filename,
parse);
407 throw std::invalid_argument(
408 "parseMeasurements<Rot2> can only convert Pose2 measurements " 409 "with Gaussian noise models.");
410 const Matrix3
M = gaussian->covariance();
412 noiseModel::Isotropic::Variance(1,
M(2, 2)));
416 std::vector<BinaryMeasurement<Rot2>>
420 auto poses = parseMeasurements<Pose2>(
filename,
model, maxIndex);
421 std::vector<BinaryMeasurement<Rot2>>
result;
422 result.reserve(poses.size());
423 for (
const auto &
p : poses)
431 std::vector<BetweenFactor<Pose2>::shared_ptr>
438 return parseToVector<BetweenFactor<Pose2>::shared_ptr>(
filename,
parse);
449 boost::optional<BinaryMeasurement<BearingRange2D>>
451 if (tag !=
"BR" && tag !=
"LANDMARK")
456 double bearing, range, bearing_std, range_std;
459 is >> bearing >> range >> bearing_std >> range_std;
463 if (tag ==
"LANDMARK") {
467 is >> lmx >> lmy >> v1 >> v2 >>
v3;
470 bearing =
atan2(lmy, lmx);
471 range =
sqrt(lmx * lmx + lmy * lmy);
477 bearing_std =
sqrt(v1 / 10.0);
478 range_std =
sqrt(v1);
487 if (maxIndex && id1 > maxIndex)
491 auto measurementNoise = noiseModel::Diagonal::Sigmas(
492 (
Vector(2) << bearing_std, range_std).finished());
501 size_t maxIndex,
bool addNoise,
bool smart,
506 auto initial = boost::make_shared<Values>();
509 if (!maxIndex || indexedPose->first <= maxIndex)
510 initial->insert(indexedPose->first, indexedPose->second);
512 if (!maxIndex || indexedLandmark->first <= maxIndex)
513 initial->insert(
L(indexedLandmark->first), indexedLandmark->second);
520 auto graph = boost::make_shared<NonlinearFactorGraph>();
524 {addNoise ?
createSampler(model) :
nullptr, maxIndex, smart, noiseFormat,
525 kernelFunctionType, model});
533 if (
auto f = parseBetweenFactor(is, tag)) {
542 }
else if (
auto m = parseBearingRange(is, tag)) {
568 bool addNoise,
bool smart,
NoiseFormat noiseFormat,
570 return load2D(dataset.first, dataset.second, maxIndex, addNoise, smart,
571 noiseFormat, kernelFunctionType);
578 return load2D(filename, model, maxIndex);
584 const string &filename) {
586 fstream
stream(filename.c_str(), fstream::out);
589 for (
const auto key_value : config) {
591 stream <<
"VERTEX2 " << key_value.key <<
" " << pose.
x() <<
" " << pose.
y()
592 <<
" " << pose.
theta() << endl;
597 Matrix3
R = model->R();
598 Matrix3 RR = R.transpose() *
R;
599 for (
auto f : graph) {
604 const Pose2 pose = factor->measured().inverse();
605 stream <<
"EDGE2 " << factor->key2() <<
" " << factor->key1() <<
" " 606 << pose.
x() <<
" " << pose.
y() <<
" " << pose.
theta() <<
" " 607 << RR(0, 0) <<
" " << RR(0, 1) <<
" " << RR(1, 1) <<
" " << RR(2, 2)
608 <<
" " << RR(0, 2) <<
" " << RR(1, 2) << endl;
622 bool addNoise =
false;
631 const string &filename) {
632 fstream
stream(filename.c_str(), fstream::out);
638 for (
const auto key_value : estimate) {
643 stream <<
"VERTEX_SE2 " << index(key_value.key) <<
" " << pose.
x() <<
" " 644 << pose.
y() <<
" " << pose.
theta() << endl;
648 for (
const auto key_value : estimate) {
655 stream <<
"VERTEX_SE3:QUAT " << index(key_value.key) <<
" " << t.x() <<
" " 656 << t.y() <<
" " << t.z() <<
" " <<
q.x() <<
" " <<
q.y() <<
" " 657 <<
q.z() <<
" " <<
q.w() << endl;
661 for (
const auto key_value : estimate) {
666 stream <<
"VERTEX_XY " << index(key_value.key) <<
" " << point.x() <<
" " 667 << point.y() << endl;
671 for (
const auto key_value : estimate) {
676 stream <<
"VERTEX_TRACKXYZ " << index(key_value.key) <<
" " << point.x()
677 <<
" " << point.y() <<
" " << point.z() << endl;
681 for (
const auto &factor_ : graph) {
687 if (!gaussianModel) {
688 model->
print(
"model\n");
689 throw invalid_argument(
"writeG2o: invalid noise model!");
691 Matrix3 Info = gaussianModel->R().transpose() * gaussianModel->R();
693 stream <<
"EDGE_SE2 " << index(factor->key1()) <<
" " 694 << index(factor->key2()) <<
" " << pose.
x() <<
" " << pose.
y()
695 <<
" " << pose.
theta();
696 for (
size_t i = 0;
i < 3;
i++) {
697 for (
size_t j =
i;
j < 3;
j++) {
709 boost::shared_ptr<noiseModel::Gaussian> gaussianModel =
711 if (!gaussianModel) {
712 model->
print(
"model\n");
713 throw invalid_argument(
"writeG2o: invalid noise model!");
715 Matrix6 Info = gaussianModel->R().transpose() * gaussianModel->R();
720 << index(
factor3D->key2()) <<
" " << p.x() <<
" " << p.y() <<
" " 721 << p.z() <<
" " <<
q.x() <<
" " <<
q.y() <<
" " <<
q.z() <<
" " 724 Matrix6 InfoG2o = I_6x6;
725 InfoG2o.block<3, 3>(0, 0) = Info.block<3, 3>(3, 3);
726 InfoG2o.block<3, 3>(3, 3) = Info.block<3, 3>(0, 0);
727 InfoG2o.block<3, 3>(0, 3) = Info.block<3, 3>(0, 3);
728 InfoG2o.block<3, 3>(3, 0) = Info.block<3, 3>(3, 0);
730 for (
size_t i = 0;
i < 6;
i++) {
731 for (
size_t j =
i;
j < 6;
j++) {
745 is >> x >> y >> z >>
w;
746 const double norm =
sqrt(w * w + x * x + y * y + z * z),
f = 1.0 / norm;
754 double yaw, pitch, roll;
755 is >> roll >> pitch >> yaw;
756 R = Rot3::Ypr(yaw, pitch, roll);
763 if (tag ==
"VERTEX3") {
767 is >>
id >> x >> y >> z >>
R;
768 return make_pair(
id,
Pose3(R, {
x,
y, z}));
769 }
else if (tag ==
"VERTEX_SE3:QUAT") {
773 is >>
id >> x >> y >> z >>
q;
774 return make_pair(
id,
Pose3(q, {
x,
y, z}));
788 if (tag ==
"VERTEX_TRACKXYZ") {
791 is >>
id >> x >> y >>
z;
792 return make_pair(
id,
Point3(x, y, z));
806 for (
size_t i = 0;
i < 6;
i++)
807 for (
size_t j =
i;
j < 6;
j++) {
822 boost::optional<BinaryMeasurement<Pose3>>
operator()(istream &is,
824 if (tag !=
"EDGE3" && tag !=
"EDGE_SE3:QUAT")
830 if (maxIndex && (id1 > maxIndex || id2 > maxIndex))
834 if (tag ==
"EDGE3") {
837 is >> x >> y >> z >> R >>
m;
841 T12 = T12.
retract(sampler->sample());
844 noiseModel::Gaussian::Information(m));
845 }
else if (tag ==
"EDGE_SE3:QUAT") {
848 is >> x >> y >> z >> q >>
m;
853 T12 = T12.
retract(sampler->sample());
857 mgtsam.block<3, 3>(0, 0) = m.block<3, 3>(3, 3);
858 mgtsam.block<3, 3>(3, 3) = m.block<3, 3>(0, 0);
859 mgtsam.block<3, 3>(0, 3) = m.block<3, 3>(0, 3);
860 mgtsam.block<3, 3>(3, 0) = m.block<3, 3>(3, 0);
864 id1, id2, T12, noiseModel::Gaussian::Information(mgtsam));
873 std::vector<BinaryMeasurement<Pose3>>
879 return parseToVector<BinaryMeasurement<Pose3>>(
filename,
parse);
890 throw std::invalid_argument(
891 "parseMeasurements<Rot3> can only convert Pose3 measurements " 892 "with Gaussian noise models.");
893 const Matrix6
M = gaussian->covariance();
896 noiseModel::Gaussian::Covariance(M.block<3, 3>(0, 0),
true));
900 std::vector<BinaryMeasurement<Rot3>>
904 auto poses = parseMeasurements<Pose3>(
filename,
model, maxIndex);
905 std::vector<BinaryMeasurement<Rot3>>
result;
906 result.reserve(poses.size());
907 for (
const auto &
p : poses)
915 std::vector<BetweenFactor<Pose3>::shared_ptr>
920 return parseToVector<BetweenFactor<Pose3>::shared_ptr>(
filename,
parse);
925 auto graph = boost::make_shared<NonlinearFactorGraph>();
926 auto initial = boost::make_shared<Values>();
935 initial->insert(indexedPose->first, indexedPose->second);
937 initial->insert(
L(indexedLandmark->first), indexedLandmark->second);
938 }
else if (
auto factor = parseFactor(is, tag)) {
939 graph->push_back(*factor);
945 return make_pair(
graph, initial);
955 Matrix3 R_mat = Matrix3::Zero(3, 3);
976 return Pose3(cRw_openGL, t_openGL);
988 ifstream is(filename.c_str(), ifstream::in);
990 cout <<
"Error in readBundler: can not find the file!!" << endl;
996 is.getline(aux, 500);
999 size_t nrPoses, nrPoints;
1000 is >> nrPoses >> nrPoints;
1003 for (
size_t i = 0;
i < nrPoses;
i++) {
1006 is >> f >> k1 >> k2;
1010 float r11, r12, r13;
1011 float r21, r22, r23;
1012 float r31, r32, r33;
1013 is >> r11 >> r12 >> r13 >> r21 >> r22 >> r23 >> r31 >> r32 >> r33;
1016 Rot3 R(r11, r12, r13, r21, r22, r23, r31, r32, r33);
1019 if (r11 == 0 && r12 == 0 && r13 == 0) {
1020 cout <<
"Error in readBundler: zero rotation matrix for pose " <<
i 1027 is >> tx >> ty >> tz;
1031 data.
cameras.emplace_back(pose, K);
1035 data.
tracks.reserve(nrPoints);
1036 for (
size_t j = 0;
j < nrPoints;
j++) {
1047 track.
r = r / 255.f;
1048 track.
g = g / 255.f;
1049 track.
b = b / 255.f;
1052 size_t nvisible = 0;
1057 for (
size_t k = 0; k < nvisible; k++) {
1058 size_t cam_idx = 0, point_idx = 0;
1060 is >> cam_idx >> point_idx >> u >>
v;
1062 track.
siftIndices.emplace_back(cam_idx, point_idx);
1065 data.
tracks.push_back(track);
1075 ifstream is(filename.c_str(), ifstream::in);
1077 cout <<
"Error in readBAL: can not find the file!!" << endl;
1082 size_t nrPoses, nrPoints, nrObservations;
1083 is >> nrPoses >> nrPoints >> nrObservations;
1085 data.
tracks.resize(nrPoints);
1088 for (
size_t k = 0; k < nrObservations; k++) {
1089 size_t i = 0,
j = 0;
1091 is >> i >>
j >> u >>
v;
1096 for (
size_t i = 0;
i < nrPoses;
i++) {
1099 is >> wx >> wy >> wz;
1100 Rot3 R = Rot3::Rodrigues(wx, wy, wz);
1104 is >> tx >> ty >> tz;
1110 is >> f >> k1 >> k2;
1113 data.
cameras.emplace_back(pose, K);
1117 for (
size_t j = 0;
j < nrPoints;
j++) {
1143 os.open(filename.c_str());
1145 if (!os.is_open()) {
1146 cout <<
"Error in writeBAL: can not open the file!!" << endl;
1151 size_t nrObservations = 0;
1153 nrObservations += data.
tracks[
j].number_measurements();
1158 << nrObservations << endl;
1167 double u0 = data.
cameras[
i].calibration().px();
1168 double v0 = data.
cameras[
i].calibration().py();
1170 if (u0 != 0 || v0 != 0) {
1171 cout <<
"writeBAL has not been tested for calibration with nonzero " 1178 double pixelBALy = -(track.
measurements[k].second.y() -
1180 Point2 pixelMeasurement(pixelBALx, pixelBALy);
1181 os << i <<
" " <<
j <<
" " 1182 << pixelMeasurement.x() <<
" " 1183 << pixelMeasurement.y() << endl;
1193 os << Rot3::Logmap(poseOpenGL.
rotation()) << endl;
1197 os << cameraCalibration.
fx() << endl;
1198 os << cameraCalibration.
k1() << endl;
1199 os << cameraCalibration.
k2() << endl;
1206 os << point.x() << endl;
1207 os << point.y() << endl;
1208 os << point.z() << endl;
1236 for (
size_t i = 0;
i < nrCameras;
i++) {
1242 cout <<
"writeBALfromValues: different number of cameras in " 1243 "SfM_dataValues (#cameras " 1245 << nrPoses <<
", #poses " << nrCameras <<
")!!" << endl;
1253 if (nrPoints != nrTracks) {
1254 cout <<
"writeBALfromValues: different number of points in " 1255 "SfM_dataValues (#points= " 1256 << nrTracks <<
") and values (#points " << nrPoints <<
")!!" << endl;
1259 for (
size_t j = 0;
j < nrTracks;
j++) {
1261 if (values.
exists(pointKey)) {
1273 return writeBAL(filename, dataValues);
1280 initial.
insert(i++, camera);
1286 size_t i = 0,
j = 0;
1288 initial.
insert((i++), camera);
1307 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V41 1308 std::map<size_t, Pose3> parse3DPoses(
const std::string &filename,
1313 std::map<size_t, Point3> parse3DLandmarks(
const std::string &filename,
const SharedNoiseModel & noiseModel() const
std::vector< BetweenFactor< Pose3 >::shared_ptr > BetweenFactorPose3s
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. ...
const T & measured() const
std::vector< BetweenFactor< Pose2 >::shared_ptr > parseFactors< Pose2 >(const std::string &filename, const noiseModel::Diagonal::shared_ptr &model, size_t maxIndex)
Matrix< RealScalar, Dynamic, Dynamic > M
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...
std::vector< BetweenFactor< Pose3 >::shared_ptr > parseFactors< Pose3 >(const std::string &filename, const noiseModel::Diagonal::shared_ptr &model, size_t maxIndex)
static vector< T > parseToVector(const string &filename, Parser< T > parse)
Define the structure for SfM data.
boost::shared_ptr< Sampler > sampler
istream & operator>>(istream &is, Matrix6 &m)
KernelFunctionType
Robust kernel type to wrap around quadratic noise model.
double k1() const
distorsion parameter k1
noiseModel::Diagonal::shared_ptr model
Q id(Eigen::AngleAxisd(0, Q_z_axis))
void insert(Key j, const Value &val)
GraphAndValues load2D(pair< string, SharedNoiseModel > dataset, size_t maxIndex, bool addNoise, bool smart, NoiseFormat noiseFormat, KernelFunctionType kernelFunctionType)
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))
Point3 unrotate(const Point3 &p, OptionalJacobian< 3, 3 > H1=boost::none, OptionalJacobian< 3, 3 > H2=boost::none) const
rotate point from world to rotated frame
std::pair< size_t, Pose2 > IndexedPose
Return type for auxiliary functions.
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
boost::optional< pair< size_t, Pose3 > > parseVertexPose3(istream &is, const string &tag)
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 ...
double k2() const
distorsion parameter k2
const Point3 & translation(OptionalJacobian< 3, 6 > Hself=boost::none) const
get translation
GraphAndValues load2D_robust(const string &filename, const noiseModel::Base::shared_ptr &model, size_t maxIndex)
boost::optional< BinaryMeasurement< BearingRange2D > > operator()(istream &is, const string &tag)
Try to guess covariance matrix layout.
Point3 rotate(const Point3 &p, OptionalJacobian< 3, 3 > H1=boost::none, OptionalJacobian< 3, 3 > H2=boost::none) const
const mpreal root(const mpreal &x, unsigned long int k, mp_rnd_t r=mpreal::get_default_rnd())
boost::optional< typename BetweenFactor< T >::shared_ptr > operator()(istream &is, const string &tag)
NonlinearFactorGraph graph
ParseFactor(const ParseMeasurement< T > &parent)
const gtsam::Key pointKey
const SharedNoiseModel & noiseModel() const
access to the noise model
BearingFactor3D factor3D(poseKey, pointKey, measurement3D, model3D)
void g(const string &key, int i)
graph add(boost::make_shared< UnaryFactor >(1, 0.0, 0.0, unaryNoise))
T compose(const T &t1, const T &t2)
static SharedNoiseModel createNoiseModel(const Vector6 v, bool smart, NoiseFormat noiseFormat, KernelFunctionType kernelFunctionType)
Rot3 inverse() const
inverse of a rotation
std::vector< SfmTrack > tracks
Sparse set of points.
NoiseFormat
Indicates how noise parameters are stored in file.
string findExampleDataFile(const string &name)
const Symbol key1('v', 1)
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
Class compose(const Class &g) const
boost::optional< BinaryMeasurement< Pose3 > > operator()(istream &is, const string &tag)
Information matrix, but inf_ff inf_fs inf_ss inf_rr inf_fr inf_sr.
Define the structure for the 3D points.
const ValueType at(Key j) const
std::function< boost::optional< T >(istream &is, const string &tag)> Parser
Rot3 openGLFixedRotation()
std::vector< BinaryMeasurement< Rot3 > > parseMeasurements(const std::string &filename, const noiseModel::Diagonal::shared_ptr &model, size_t maxIndex)
double theta() const
get theta
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
bool convert(const int &y)
KernelFunctionType kernelFunctionType
std::pair< size_t, Point2 > IndexedLandmark
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
boost::optional< BinaryMeasurement< Pose2 > > operator()(istream &is, const string &tag)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DEVICE_FUNC const Scalar & q
void save2D(const NonlinearFactorGraph &graph, const Values &config, const noiseModel::Diagonal::shared_ptr model, const string &filename)
Pose3 gtsam2openGL(const Pose3 &PoseGTSAM)
This function converts a GTSAM camera pose to an openGL camera pose.
sampling from a NoiseModel
void print(const std::string &name) const override
size_t number_measurements() const
Total number of measurements in this track.
boost::shared_ptr< Sampler > createSampler(const SharedNoiseModel &model)
string createRewrittenFileName(const string &name)
boost::shared_ptr< Diagonal > shared_ptr
BearingRange< Pose2, Point2 > BearingRange2D
Values initialCamerasEstimate(const SfmData &db)
This function creates initial values for cameras from db.
Base class and basic functions for Lie types.
boost::shared_ptr< Base > shared_ptr
Jet< T, N > atan2(const Jet< T, N > &g, const Jet< T, N > &f)
boost::optional< pair< size_t, Point3 > > parseVertexPoint3(istream &is, const string &tag)
typedef and functions to augment Eigen's VectorXd
Class retract(const TangentVector &v) const
retract as required by manifold concept: applies v at *this
GTSAM_EXPORT Point2 transformFrom(const Point2 &point, OptionalJacobian< 2, 3 > Dpose=boost::none, OptionalJacobian< 2, 2 > Dpoint=boost::none) const
std::vector< SfmCamera > cameras
Set of cameras.
Covariance matrix C11, C12, C13, C22, C23, C33.
map< size_t, T > parseToMap(const string &filename, Parser< pair< size_t, T >> parse, size_t maxIndex)
Information matrix I11, I12, I13, I22, I23, I33.
Non-linear factor base classes.
ofstream os("timeSchurFactors.csv")
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
The quaternion class used to represent 3D orientations and rotations.
std::vector< BetweenFactor< Pose2 >::shared_ptr > BetweenFactorPose2s
std::map< size_t, Point3 > parseVariables< Point3 >(const std::string &filename, size_t maxIndex)
const Symbol key2('v', 2)
Point3 p
3D position of the point
float b
RGB color of the 3D point.
The base class for any variable that can be optimized or used in a factor.
std::map< size_t, Pose2 > parseVariables< Pose2 >(const std::string &filename, size_t maxIndex)
std::map< size_t, Pose3 > parseVariables< Pose3 >(const std::string &filename, size_t maxIndex)
double fx() const
focal length x
Annotation for function names.
Values initialCamerasAndPointsEstimate(const SfmData &db)
This function creates initial values for cameras and points from db.
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...
static void parseLines(const string &filename, Parser< T > parse)
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)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
GraphAndValues load3D(const string &filename)
Load TORO 3D Graph.
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
def parse(input_path, output_path, quiet=False, generate_xml_flag=True)
std::map< size_t, Point2 > parseVariables< Point2 >(const std::string &filename, size_t maxIndex)
boost::optional< IndexedLandmark > parseVertexLandmark(istream &is, const string &tag)
utility functions for loading datasets
gtsam::Quaternion toQuaternion() const
std::vector< SfmMeasurement > measurements
The 2D image projections (id,(u,v))
std::uint64_t Key
Integer nonlinear key type.
noiseModel::Base::shared_ptr SharedNoiseModel
boost::shared_ptr< Sampler > sampler
const Rot3 & rotation(OptionalJacobian< 3, 6 > Hself=boost::none) const
get rotation
3D rotation represented as a rotation matrix or quaternion
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...
std::uint64_t index() const
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...
Eigen::Quaternion< double, Eigen::DontAlign > Quaternion
size_t number_cameras() const