Skip to content
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

Fix bugs in loop detection #745

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Conversation

fishmarch
Copy link

The iterator is not updated when the pKFi is bad, thus it will get stuck in the loop. In our modified SLAM system, this would happen. But I am not sure in the origin version whether pKFi could be bad thus causing this problem. Please check.

src/KeyFrameDatabase.cc Outdated Show resolved Hide resolved
Co-authored-by: Nicolas Soncini <[email protected]>
@jeremysalwen
Copy link

Hello @fishmarch, I am creating a community version of ORB_SLAM3 at https://github.com/jeremysalwen/ORB_SLAM_COMMUNITY since this repository seems to be inactive. These bugfixes seem very interesting but I am having a hard time understanding some of them. I have already merged most of your patches, but the Sim3Solver and DetectNBestCandidates changes are not self-evident to me. Could you explain a bit more the reasoning behind those changes?

@fishmarch
Copy link
Author

Hi @jeremysalwen , I am glad to help.

You mean those bugs fixed in my repo https://github.com/fishmarch/ORB_SLAM3_Fixed ?

Sim3Solver

Before Sim3Solver, the current keyframe mpCurrentKF is matched with the candidate keyframe pMostBoWMatchesKF and its neighbors vpCovKFi. The result vpMatchedPoints contains all matched mappoints. Note that not all matched map points are from the candidate keyframe pMostBoWMatchesKF, and thus vpKeyFrameMatchedMP contains the corresponding keyframes.

Therefore in Sim3Solver, the flag bDifferentKFs should be ture by default, and then the related keyframe pKFm can be retrieved correctly. By the way, it seems vpKeyFrameMatchedMP will never be empty, if there are matched mappoints...

DetectNBestCandidates

The first bug is to update the iteration for bad keyframe for

if(pKFi->isBad())
continue;

The similarity score is accumulated in neighbors in

accScore+=pKF2->mPlaceRecognitionScore;

Thus it needs to ensure the similarity score is calculated with the current candidate keyframe. But it was calculated only under the following condition:

if(pKFi->mnPlaceRecognitionWords>minCommonWords)
{
nscores++;
float si = mpVoc->score(pKF->mBowVec,pKFi->mBowVec);
pKFi->mPlaceRecognitionScore=si;
lScoreAndMatch.push_back(make_pair(si,pKFi));
}

@jeremysalwen
Copy link

Hmm, ok the Sim3Solver code makes sense to me and I merged it, but for the DetectNBestCandidates, Are you sure that it is calculating the right score?

float si = mpVoc->score(pKF->mBowVec,pKFi->mBowVec);

Shouldn't it be scoring pKF2?

@fishmarch
Copy link
Author

Yes, it is pKF2 in my repo. pKFi is the original codes.

@jeremysalwen
Copy link

Oh I see you fixed it in later commits. Okay that makes sense.

I'm still not clear if the original intention was to ignore covisibility keyframes that don't have enough common words, or to dynamically score then like you have. I assume it works fine to ignore them, since the original code was using invalid scores?

@fishmarch
Copy link
Author

Yes, agree with you. These similarity score can also be set to zero directly. It is hard to say which one is better, but setting to zeros can be faster than my codes. Anyway the original codes need to be modified, since using wrong scores computed from previous keyframes.

@jeremysalwen
Copy link

Hmm, something else I noticed, DetectNBestCandidates (where this code change is) only is called inside NewDetectCommonRegions, which itself isn't called anywhere... is all of this code dead?

@fishmarch
Copy link
Author

NewDetectCommonRegions is called in LoopClosing::Run() at:

bool bFindedRegion = NewDetectCommonRegions();

@jeremysalwen
Copy link

Ah, just a bug in github search:
image

It is indeed used. Thanks again, I will incorporate everything into the community fork :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants