Skip to content

Commit e6296b8

Browse files
committed
[filterSfM] fix NaN
1 parent 63c7e50 commit e6296b8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/software/pipeline/main_filterSfM.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct LandmarksAdaptator
7171
}
7272

7373
// Must return the number of data points
74-
inline size_t kdtree_get_point_count() const { return _data.size(); }
74+
inline size_t kdtree_get_point_count() const { return usePtr ? _data_ptr.size() : _data.size(); }
7575

7676
// Returns the dim'th component of the idx'th point in the class:
7777
inline T kdtree_get_pt(const size_t idx, int dim) const
@@ -342,8 +342,12 @@ bool filterObservations(SfMData& sfmData, int maxNbObservationsPerLandmark, int
342342
{
343343
// weight is the inverse of distance between a landmark and its neighbor
344344
w = 1. / std::sqrt(w);
345+
if(std::isinf(w))
346+
w = std::numeric_limits<double>::max();
345347
total += w;
346348
}
349+
if(std::isinf(total))
350+
total = std::numeric_limits<double>::max();
347351
// normalize weights
348352
for(auto& w : weights_)
349353
{
@@ -401,6 +405,9 @@ bool filterObservations(SfMData& sfmData, int maxNbObservationsPerLandmark, int
401405
}
402406
}
403407
}
408+
// if no common views with neighbor landmarks
409+
if(viewScores_total == 0.)
410+
continue;
404411
for(auto j = 0; j < viewScores_acc.size(); j++)
405412
{
406413
// normalize score and apply influence factor

0 commit comments

Comments
 (0)