Skip to content

Commit

Permalink
Add saveMap() function
Browse files Browse the repository at this point in the history
  • Loading branch information
zeryabmoussaoui committed Aug 28, 2018
1 parent d5f4f41 commit 5f017f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 113,7 @@ class System
void SaveTrajectoryKITTI(const string &filename);

// TODO: Save/Load functions
// SaveMap(const string &filename);
void SaveMap(const string &filename);
// LoadMap(const string &filename);

// Information from most recent processed frame
Expand Down
26 changes: 24 additions & 2 deletions src/System.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 418,30 @@ void System::SaveKeyFrameTrajectoryTUM(const string &filename)
cout << endl << "trajectory saved!" << endl;
}

void System::SaveMap(const string &filename)
{

vector<MapPoint*> vMPs = mpMap->GetAllMapPoints();

ofstream f;
f.open(filename.c_str());
f << fixed;

vector<MapPoint*>::iterator itvMps;
// Iterate over all points
for(itvMps = vMPs.begin(); itvMps != vMPs.end() ; itvMps )
{
MapPoint* mp = *itvMps;

cv::Mat pos = cv::Mat::eye(3,1,CV_32F);
pos = mp->GetWorldPos();

f << pos.at<float>(0) << ", " << pos.at<float>(1) << ", " << pos.at<float>(2) << endl;
}
f.close();
}


void System::SaveTrajectoryKITTI(const string &filename)
{
cout << endl << "Saving camera trajectory to " << filename << " ..." << endl;
Expand Down Expand Up @@ -475,8 499,6 @@ void System::SaveTrajectoryKITTI(const string &filename)





int System::GetTrackingState()
{
unique_lock<mutex> lock(mMutexState);
Expand Down

0 comments on commit 5f017f7

Please sign in to comment.