Skip to content

Commit 5828fa1

Browse files
committed
[WIP][filterSfM] fix bug in neighbor search
1 parent eb36bcc commit 5828fa1

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/software/pipeline/main_filterSfM.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,19 @@ class KnnNonZeroSearch
306306
{
307307
if(i < capacity)
308308
{
309-
if(i > 0)
310-
if(count < capacity)
309+
if(i != count)
310+
{
311+
if (count < capacity)
312+
{
311313
std::move_backward(&indices[i], &indices[count], &indices[count + 1]);
314+
std::move_backward(&dists[i], &dists[count], &dists[count + 1]);
315+
}
312316
else
317+
{
313318
std::move_backward(&indices[i], &indices[capacity - 1], &indices[capacity]);
319+
std::move_backward(&dists[i], &dists[capacity - 1], &dists[capacity]);
320+
}
321+
}
314322
dists[i] = dist;
315323
indices[i] = index;
316324
}
@@ -729,15 +737,15 @@ void computeNewScores(const std::vector<Landmark*>& landmarksData,
729737
}
730738
}
731739
// if common views with neighbor landmarks
732-
if(viewScores_total != 0.)
733-
for(auto j = 0; j < viewScores_acc.size(); j++)
734-
{
735-
// normalize score and apply influence factor
736-
//viewScores_acc[j] *= params.neighborsInfluence / viewScores_total;
737-
viewScores_acc[j] *= params.neighborsInfluence;
738-
// combine weighted neighbor scores and the landmark's own scores
739-
viewScores_acc[j] += (1 - params.neighborsInfluence) * viewScores[j];
740-
}
740+
//if(viewScores_total != 0.)
741+
for(auto j = 0; j < viewScores_acc.size(); j++)
742+
{
743+
// normalize score and apply influence factor
744+
//viewScores_acc[j] *= params.neighborsInfluence / viewScores_total;
745+
viewScores_acc[j] *= params.neighborsInfluence;
746+
// combine weighted neighbor scores and the landmark's own scores
747+
viewScores_acc[j] += (1 - params.neighborsInfluence) * viewScores[j];
748+
}
741749

742750
// dampen scores of non-chosen observations
743751
if(params.dampingEnabled && viewScores_acc.size() <= params.maxNbObservationsPerLandmark)
@@ -843,11 +851,12 @@ bool filterObservations3D(SfMData& sfmData, const FilterParams::FilterObservatio
843851

844852
// keep only observations with best scores
845853
Observations filteredObservations;
854+
//double threshold = 0.1 / params.maxNbObservationsPerLandmark;
846855
for(auto j = 0; j < params.maxNbObservationsPerLandmark; j++)
847856
{
848857
const auto& viewScore = viewScores[idx[j]];
849-
if(viewScore < 0.3)
850-
break;
858+
/*if(viewScore < threshold)
859+
break;*/
851860
const auto& viewId = viewIds[idx[j]];
852861
filteredObservations[viewId] = landmark.observations[viewId];
853862
}

0 commit comments

Comments
 (0)