@@ -58,8 +58,8 @@ struct ObservationsAdaptator
58
58
// / CRTP helper method
59
59
inline Derived& derived () { return *static_cast <Derived*>(this ); }
60
60
61
- const std::vector<const Observation* > _data;
62
- ObservationsAdaptator (const std::vector<const Observation* >& data)
61
+ const std::vector<Observation> _data;
62
+ ObservationsAdaptator (const std::vector<Observation>& data)
63
63
: _data(data)
64
64
{
65
65
}
@@ -68,7 +68,7 @@ struct ObservationsAdaptator
68
68
inline size_t kdtree_get_point_count () const { return _data.size (); }
69
69
70
70
// Returns the dim'th component of the idx'th point in the class:
71
- inline T kdtree_get_pt (const size_t idx, int dim) const { return _data[idx]-> x (dim); }
71
+ inline T kdtree_get_pt (const size_t idx, int dim) const { return _data[idx]. x (dim); }
72
72
73
73
// Optional bounding-box computation: return false to default to a standard bbox computation loop.
74
74
// Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it
@@ -191,6 +191,30 @@ class PixSizeSearch
191
191
inline double worstDist () const { return _radius_sq; }
192
192
};
193
193
194
+ using ObservationsPerView = stl::flat_map<std::size_t , std::pair<std::vector<Observation>, std::vector<Landmark*>>>;
195
+
196
+ /* *
197
+ * @brief Get the landmark observations of camera views
198
+ * with the corresponding landmarks information.
199
+ * @param[in] sfmData: A given SfMData
200
+ * @return Observation information per camera view
201
+ */
202
+ ObservationsPerView getObservationsPerViews (SfMData& sfmData)
203
+ {
204
+ ObservationsPerView observationsPerView;
205
+ for (auto & landIt : sfmData.getLandmarks ())
206
+ {
207
+ for (const auto & obsIt : landIt.second .observations )
208
+ {
209
+ IndexT viewId = obsIt.first ;
210
+ auto & landmarksSet = observationsPerView[viewId];
211
+ landmarksSet.first .push_back (obsIt.second );
212
+ landmarksSet.second .push_back (&landIt.second );
213
+ }
214
+ }
215
+ return observationsPerView;
216
+ }
217
+
194
218
bool filterLandmarks (SfMData& sfmData, double radiusScale, bool useFeatureScale, int minNbObservationsPerLandmark)
195
219
{
196
220
const auto initialNbLandmarks = sfmData.getLandmarks ().size ();
@@ -648,7 +672,7 @@ bool filterObservations2D(SfMData& sfmData, int nbNeighbors2D, float percentile,
648
672
std::advance (itView, i);
649
673
const IndexT viewId = *itView;
650
674
651
- auto & observationsIt = observationsPerView.find (viewId);
675
+ auto observationsIt = observationsPerView.find (viewId);
652
676
if (observationsIt == observationsPerView.end ())
653
677
continue ;
654
678
@@ -669,7 +693,7 @@ bool filterObservations2D(SfMData& sfmData, int nbNeighbors2D, float percentile,
669
693
cacheSize);
670
694
for (auto j = 0 ; j < observations.size (); j++)
671
695
{
672
- const auto & obs = * observations[j];
696
+ const auto & obs = observations[j];
673
697
std::vector<size_t > indices_ (nbNeighbors_);
674
698
std::vector<double > distances_ (nbNeighbors_);
675
699
tree.knnSearch (obs.x .data (), nbNeighbors_, &indices_[0 ], &distances_[0 ]);
@@ -694,7 +718,7 @@ bool filterObservations2D(SfMData& sfmData, int nbNeighbors2D, float percentile,
694
718
}
695
719
estimatedRadii_[i] = radius;
696
720
697
- std::vector<const Observation* > filteredObservations;
721
+ std::vector<Observation> filteredObservations;
698
722
std::vector<Landmark*> filteredLandmarks;
699
723
filteredObservations.reserve (observations.size ());
700
724
filteredLandmarks.reserve (landmarks.size ());
@@ -724,14 +748,14 @@ bool filterObservations2D(SfMData& sfmData, int nbNeighbors2D, float percentile,
724
748
if (estimatedRadii_[i] != -1 .)
725
749
estimatedRadii[viewId] = estimatedRadii_[i];
726
750
727
- auto & observationsIt = observationsPerView.find (viewId);
751
+ auto observationsIt = observationsPerView.find (viewId);
728
752
if (observationsIt != observationsPerView.end ())
729
753
{
730
754
auto & observations = observationsIt->second .first ;
731
755
auto & landmarks = observationsIt->second .second ;
732
756
for (int j = 0 ; j < observations.size (); j++)
733
757
{
734
- landmarks[j]->observations [viewId] = * observations[j];
758
+ landmarks[j]->observations [viewId] = observations[j];
735
759
}
736
760
}
737
761
}
@@ -754,7 +778,7 @@ int aliceVision_main(int argc, char *argv[])
754
778
double neighborsInfluence = 0.5 ;
755
779
int nbIterations = 5 ;
756
780
int nbNeighbors2D = 5 ;
757
- float percentile = 0.95 ;
781
+ float percentile = 0 .95f ;
758
782
759
783
// user optional parameters
760
784
std::vector<std::string> featuresFolders;
0 commit comments