raulmur / ORB_SLAM2

Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities
Other
9.44k stars 4.69k forks source link

bug: DetectRelocalizationCandidates #888

Open ZhihaiYan opened 4 years ago

ZhihaiYan commented 4 years ago

I find sometimes the value of score in function DetectRelocalizationCandidates is negtive

for(list<pair<float,KeyFrame> >::iterator it=lScoreAndMatch.begin(), itend=lScoreAndMatch.end(); it!=itend; it++) { KeyFrame pKFi = it->second; vector<KeyFrame*> vpNeighs = pKFi->GetBestCovisibilityKeyFrames(10);

    float bestScore = it->first;
    float accScore = bestScore;
    KeyFrame* pBestKF = pKFi;
    for(vector<KeyFrame*>::iterator vit=vpNeighs.begin(), vend=vpNeighs.end(); vit!=vend; vit++)
    {
        KeyFrame* pKF2 = *vit;
        if(pKF2->mnRelocQuery!=F->mnId)
            continue;
        // i think here need to calculate the mRelocScore, because sometimes this value is not initialed
        pKF2->mRelocScore = mpVoc->score(F->mBowVec,pKF2->mBowVec);
        accScore+=pKF2->mRelocScore;
        if(pKF2->mRelocScore>bestScore)
        {
            pBestKF=pKF2;
            bestScore = pKF2->mRelocScore;
        }

    }
    lAccScoreAndMatch.push_back(make_pair(accScore,pBestKF));
    if(accScore>bestAccScore)
        bestAccScore=accScore;
}
zherlock030 commented 4 years ago

I found that, too. accScore+=pKF2->mRelocScore; here the pKF2->mRelocScore was not calculated, it is a intial value, u need to calculate it by yourself.