Skip to content

Commit 4dbe6c0

Browse files
committed
set new parameter for HF-Net
1 parent b1e5778 commit 4dbe6c0

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

.vscode/settings.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

modules/rgbd/src/keyframe.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,15 @@ int KeyFrameDatabase::getLastKeyFrameID()
139139
double KeyFrameDatabase::score(InputArray feature1, InputArray feature2)
140140
{
141141
Mat mat1, mat2;
142+
142143
mat1 = feature1.getMat();
143144
mat2 = feature2.getMat();
145+
CV_Assert(mat1.size() == mat2.size());
144146
double out = mat2.dot(mat1);
145147
return out;
146148
}
147149

148-
std::vector<int> KeyFrameDatabase::getCandidateKF(const Mat& currentFeature, const double& similarityLow, double& bestSimilarity, int& bestId)
150+
std::vector<int> KeyFrameDatabase::getCandidateKF(const Mat& currentFeature, const int currentSubmapID, const double& similarityLow, double& bestSimilarity, int& bestId )
149151
{
150152
std::vector<int> cadidateKFs;
151153
float similarity;
@@ -154,6 +156,8 @@ std::vector<int> KeyFrameDatabase::getCandidateKF(const Mat& currentFeature, con
154156

155157
for(std::map<int, Ptr<KeyFrame> >::const_iterator iter = DataBase.begin(); iter != DataBase.end(); iter++)
156158
{
159+
if( currentSubmapID != -1 && currentSubmapID == iter->second->submapID)
160+
continue;
157161
similarity = score(currentFeature, iter->second->DNNFeature);
158162

159163
if(similarity > similarityLow)

modules/rgbd/src/keyframe.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class KeyFrameDatabase
5959

6060
int getLastKeyFrameID();
6161

62-
std::vector<int> getCandidateKF(const Mat& currentFeature, const double& similarityLow, double& bestSimilarity, int& bestId);
62+
std::vector<int> getCandidateKF(const Mat& currentFeature, const int currentSubmapID, const double& similarityLow, double& bestSimilarity, int& bestId);
6363

6464
double score(InputArray feature1, InputArray feature2);
6565

modules/rgbd/src/loop_closure_detection.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ bool LoopClosureDetectionImpl::loopCheck(int& tarSubmapID)
4343
std::vector<int> candidateKFs;
4444

4545
// Find candidate key frames which similarity are greater than the similarityLow.
46-
candidateKFs = KFDataBase->getCandidateKF(currentDNNFeature, similarityLow, maxScore, bestId);
46+
candidateKFs = KFDataBase->getCandidateKF(currentDNNFeature, currentSubmapID, similarityLow, maxScore, bestId);
47+
48+
CV_LOG_INFO(NULL, "LCD: Best Frame ID = " << bestId<<", similarity = "<<maxScore);
4749

4850
if( candidateKFs.empty() || maxScore < similarityHigh)
4951
return false;
@@ -77,18 +79,6 @@ bool LoopClosureDetectionImpl::loopCheck(int& tarSubmapID)
7779
}
7880
}
7981

80-
// Remove the keyframe belonging to the currentSubmap.
81-
iter = candidateKFs.begin();
82-
while (iter != candidateKFs.end() )
83-
{
84-
Ptr<KeyFrame> keyFrameDB = KFDataBase->getKeyFrameByID(*iter);
85-
if(keyFrameDB->submapID == currentFrameID)
86-
{
87-
candidateKFs.erase(iter);
88-
}
89-
iter++;
90-
}
91-
9282
// If all candidate KF from the same submap, then return true.
9383
int tempSubmapID = -1;
9484
iter = candidateKFs.begin();
@@ -107,7 +97,6 @@ bool LoopClosureDetectionImpl::loopCheck(int& tarSubmapID)
10797
}
10898
iter++;
10999
}
110-
111100
// Check whether currentFrame is closed to previous looped Keyframe.
112101
if(currentFrameID - preLoopedKFID < 20)
113102
return false;
@@ -157,7 +146,7 @@ bool LoopClosureDetectionImpl::ORBMather(InputArray feature1, InputArray feature
157146
}
158147
if(goodMatches.size() < ORBminMathing)
159148
{
160-
CV_LOG_INFO(NULL, "LOOP CLOSURE: There are too few ORB matching pairs.");
149+
CV_LOG_INFO(NULL, "LCD: There are too few ORB matching pairs.");
161150
return false;
162151
}
163152
else
@@ -217,6 +206,7 @@ void LoopClosureDetectionImpl::processFrame(InputArray img, Mat& DNNfeature, std
217206

218207
// DNN processing.
219208
Mat imgBlur, outDNN, outORB;
209+
imgBlur = img.getMat();
220210
Mat blob = dnn::blobFromImage(imgBlur, 1.0, inputSize);
221211

222212
net->setInput(blob);

modules/rgbd/src/loop_closure_detection.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class LoopClosureDetectionImpl : public LoopClosureDetection
6161
// Param: HF-Net
6262
// Github Link: https://github.com/ethz-asl/hfnet
6363
std::vector<String> outNameDNN;
64-
double similarityHigh = 0.64;
65-
double similarityLow = 0.60;
64+
double similarityHigh = 0.80;
65+
double similarityLow = 0.84;
6666

6767
};
6868

6969
}
7070
}
71-
#endif
71+
#endif

0 commit comments

Comments
 (0)