-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Save/Load Atlas Functionality #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
980ac9b
Boost serialization code + PreSave/PostLoad functions
0ce0d6d
Serialization code + added constructor for KFDB loading
3e58a1f
Serialization code + added include for tuple serialization
ae0ed23
Load/Save Atlas functions declaration
b3a7adc
PreSave/PostLoad code added
c4ce511
Functions for Save/Load + constructor + avoid infinite loop in Detect…
9e603a7
avoid failure in 1st LBA post merge
3ae3981
added condition in color index
2dd5fef
PreSave/PostLoad functions + avoid getting empty camera center
a9948ee
Added include and examples
ea2da47
Save/Load Functions
a77e821
Set StepbyStep
dcbb819
Added include and example code
114227e
Add Mono scripts in CMakeLists.txt
c9316ed
Unserialize MspMaps
ce8a338
Mono Scripts
d2f6ddd
Add Mono code lines
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -867,6 +867,177 @@ void KeyFrame::UpdateMap(Map* pMap) | |
| mpMap = pMap; | ||
| } | ||
|
|
||
| void KeyFrame::PreSave(set<KeyFrame*>& spKF,set<MapPoint*>& spMP, set<GeometricCamera*>& spCam) | ||
| { | ||
| /* | ||
| // Save the id of each MapPoint in this KF, there can be null pointer in the vector | ||
| mvBackupMapPointsId.clear(); | ||
| mvBackupMapPointsId.reserve(N); | ||
| for(int i = 0; i < N; ++i) | ||
| { | ||
|
|
||
| if(mvpMapPoints[i] && spMP.find(mvpMapPoints[i]) != spMP.end()) // Checks if the element is not null | ||
| mvBackupMapPointsId.push_back(mvpMapPoints[i]->mnId); | ||
| else // If the element is null his value is -1 because all the id are positives | ||
| mvBackupMapPointsId.push_back(-1); | ||
| } | ||
| //cout << "KeyFrame: ID from MapPoints stored" << endl; | ||
| */ | ||
|
|
||
| // Save the id of each connected KF with it weight | ||
| mBackupConnectedKeyFrameIdWeights.clear(); | ||
| for(std::map<KeyFrame*,int>::const_iterator it = mConnectedKeyFrameWeights.begin(), end = mConnectedKeyFrameWeights.end(); it != end; ++it) | ||
| { | ||
| if(spKF.find(it->first) != spKF.end()) | ||
| mBackupConnectedKeyFrameIdWeights[it->first->mnId] = it->second; | ||
| } | ||
| //cout << "KeyFrame: ID from connected KFs stored" << endl; | ||
| // Save the parent id | ||
| mBackupParentId = -1; | ||
| if(mpParent && spKF.find(mpParent) != spKF.end()) | ||
| mBackupParentId = mpParent->mnId; | ||
| //cout << "KeyFrame: ID from Parent KF stored" << endl; | ||
| // Save the id of the childrens KF | ||
| mvBackupChildrensId.clear(); | ||
| mvBackupChildrensId.reserve(mspChildrens.size()); | ||
| for(KeyFrame* pKFi : mspChildrens) | ||
| { | ||
| if(spKF.find(pKFi) != spKF.end()) | ||
| mvBackupChildrensId.push_back(pKFi->mnId); | ||
| } | ||
| //cout << "KeyFrame: ID from Children KFs stored" << endl; | ||
| // Save the id of the loop edge KF | ||
| mvBackupLoopEdgesId.clear(); | ||
| mvBackupLoopEdgesId.reserve(mspLoopEdges.size()); | ||
| for(KeyFrame* pKFi : mspLoopEdges) | ||
| { | ||
| if(spKF.find(pKFi) != spKF.end()) | ||
| mvBackupLoopEdgesId.push_back(pKFi->mnId); | ||
| } | ||
| //cout << "KeyFrame: ID from Loop KFs stored" << endl; | ||
| // Save the id of the merge edge KF | ||
| mvBackupMergeEdgesId.clear(); | ||
| mvBackupMergeEdgesId.reserve(mspMergeEdges.size()); | ||
| for(KeyFrame* pKFi : mspMergeEdges) | ||
| { | ||
| if(spKF.find(pKFi) != spKF.end()) | ||
| mvBackupMergeEdgesId.push_back(pKFi->mnId); | ||
| } | ||
| //cout << "KeyFrame: ID from Merge KFs stored" << endl; | ||
|
|
||
| //Camera data | ||
| mnBackupIdCamera = -1; | ||
| if(mpCamera && spCam.find(mpCamera) != spCam.end()) | ||
| mnBackupIdCamera = mpCamera->GetId(); | ||
| //cout << "KeyFrame: ID from Camera1 stored; " << mnBackupIdCamera << endl; | ||
|
|
||
| mnBackupIdCamera2 = -1; | ||
| if(mpCamera2 && spCam.find(mpCamera2) != spCam.end()) | ||
| mnBackupIdCamera2 = mpCamera2->GetId(); | ||
| //cout << "KeyFrame: ID from Camera2 stored; " << mnBackupIdCamera2 << endl; | ||
|
|
||
| //Inertial data | ||
| mBackupPrevKFId = -1; | ||
| if(mPrevKF && spKF.find(mPrevKF) != spKF.end()) | ||
| mBackupPrevKFId = mPrevKF->mnId; | ||
| //cout << "KeyFrame: ID from Prev KF stored" << endl; | ||
| mBackupNextKFId = -1; | ||
| if(mNextKF && spKF.find(mNextKF) != spKF.end()) | ||
| mBackupNextKFId = mNextKF->mnId; | ||
| //cout << "KeyFrame: ID from NextKF stored" << endl; | ||
| if(mpImuPreintegrated) | ||
| mBackupImuPreintegrated.CopyFrom(mpImuPreintegrated); | ||
| //cout << "KeyFrame: Imu Preintegrated stored" << endl; | ||
| } | ||
|
|
||
| void KeyFrame::PostLoad(map<long unsigned int, KeyFrame*>& mpKFid, map<long unsigned int, MapPoint*>& mpMPid, map<unsigned int, GeometricCamera*>& mpCamId){ | ||
| // Rebuild the empty variables | ||
|
|
||
| // Pose | ||
| SetPose(Tcw); | ||
|
|
||
| /* | ||
| // Reference reconstruction | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why comment on these lines? |
||
| // Each MapPoint sight from this KeyFrame | ||
| mvpMapPoints.clear(); | ||
| mvpMapPoints.resize(N); | ||
| for(int i=0; i<N; ++i) | ||
| { | ||
| if(mvBackupMapPointsId[i] != -1) | ||
| mvpMapPoints[i] = mpMPid[mvBackupMapPointsId[i]]; | ||
| else | ||
| mvpMapPoints[i] = static_cast<MapPoint*>(NULL); | ||
| } | ||
|
|
||
| */ | ||
|
|
||
| // Conected KeyFrames with him weight | ||
| mConnectedKeyFrameWeights.clear(); | ||
| for(map<long unsigned int, int>::const_iterator it = mBackupConnectedKeyFrameIdWeights.begin(), end = mBackupConnectedKeyFrameIdWeights.end(); | ||
| it != end; ++it) | ||
| { | ||
| KeyFrame* pKFi = mpKFid[it->first]; | ||
| mConnectedKeyFrameWeights[pKFi] = it->second; | ||
| } | ||
|
|
||
| // Restore parent KeyFrame | ||
| if(mBackupParentId>=0) | ||
| mpParent = mpKFid[mBackupParentId]; | ||
|
|
||
| // KeyFrame childrens | ||
| mspChildrens.clear(); | ||
| for(vector<long unsigned int>::const_iterator it = mvBackupChildrensId.begin(), end = mvBackupChildrensId.end(); it!=end; ++it) | ||
| { | ||
| mspChildrens.insert(mpKFid[*it]); | ||
| } | ||
|
|
||
| // Loop edge KeyFrame | ||
| mspLoopEdges.clear(); | ||
| for(vector<long unsigned int>::const_iterator it = mvBackupLoopEdgesId.begin(), end = mvBackupLoopEdgesId.end(); it != end; ++it) | ||
| { | ||
| mspLoopEdges.insert(mpKFid[*it]); | ||
| } | ||
|
|
||
| // Merge edge KeyFrame | ||
| mspMergeEdges.clear(); | ||
| for(vector<long unsigned int>::const_iterator it = mvBackupMergeEdgesId.begin(), end = mvBackupMergeEdgesId.end(); it != end; ++it) | ||
| { | ||
| mspMergeEdges.insert(mpKFid[*it]); | ||
| } | ||
|
|
||
| //Camera data | ||
| if(mnBackupIdCamera >= 0) | ||
| { | ||
| mpCamera = mpCamId[mnBackupIdCamera]; | ||
| } | ||
| if(mnBackupIdCamera2 >= 0) | ||
| { | ||
| mpCamera2 = mpCamId[mnBackupIdCamera2]; | ||
| } | ||
|
|
||
| //Inertial data | ||
| if(mBackupPrevKFId != -1) | ||
| { | ||
| mPrevKF = mpKFid[mBackupPrevKFId]; | ||
| } | ||
| if(mBackupNextKFId != -1) | ||
| { | ||
| mNextKF = mpKFid[mBackupNextKFId]; | ||
| } | ||
| mpImuPreintegrated = &mBackupImuPreintegrated; | ||
|
|
||
|
|
||
| // Remove all backup container | ||
| mvBackupMapPointsId.clear(); | ||
| mBackupConnectedKeyFrameIdWeights.clear(); | ||
| mvBackupChildrensId.clear(); | ||
| mvBackupLoopEdgesId.clear(); | ||
|
|
||
| UpdateBestCovisibles(); | ||
|
|
||
| //ComputeSceneMedianDepth(); | ||
| } | ||
|
|
||
| bool KeyFrame::ProjectPointDistort(MapPoint* pMP, cv::Point2f &kp, float &u, float &v) | ||
| { | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use for(Map* pMi : mspMaps) here directly, since mspMaps is already stored and mvpBackupMaps may be not necessary