Open Fredrum opened 4 years ago
I think I got that scoring to work by just using a regular ORBVocabulary and it's score() function. But I don't seem to get any good matching happening in the way Iv'e added to the ORB SLAM2 code atm. For now Iv'e basically just added this code,
// pimatch
std::mt19937 rng;
int N = 1;
uint32_t *matches = new uint32_t[N];
uint8_t *queries = new uint8_t[N*32];
for (size_t i = 0; i < N*32; i += 1) {
queries[i] = rng();
}
mpORBvocabulary->ApproxNN(matches, queries, N);
for (size_t i = 0; i < N; i += 1) {
uint32_t match = matches[i] & 0xffffff;
float weight = mpORBvocabulary->GetWeight(match);
// DBoW treats 0 as stop word
if (weight > 0.f) {
size_t classified = pPimatchClassifier->Classify(match);
mBowVec.addWeight(match, weight);
mFeatVec.addFeature(classified, i);
}
}
in place of
mpORBvocabulary->transform(vCurrentDesc,mBowVec,mFeatVec,4);
Iv'e replaced mpORBvocabulary to now be a pointer to the pimatch::HammingTree instead. There's probably a few places where I have made mistakes but it would be awesome if I could have a comment to say if it should work as I have it above?
For example they are passing that '4' number that I believe is 'LevelsUp'. So not sure if I need to do something to match that?
EDIT: Hmm...I guess the queries needs to be something else than random numbers? :) Should I pass 'vCurrentDesc' there?
Cheers Fred
Hi! I'm attempting to swap this into the orb slam 2 code and am noticing a ->score() in the original code. https://github.com/raulmur/ORB_SLAM2/blob/f2e6f51cdc8d067655d90a78c06261378e07e8f3/src/LoopClosing.cc#L134
I can't find the thing in pimatch that maps onto that. Is that supported or was that added on later?
EDIT: Hmm, maybe I can just use the ScoringObject from DBoW2 directly and it doesn't need to be the object holding the bow library/data...I will try this.
Cheers Fred