@@ -58,8 +58,8 @@ struct ObservationsAdaptator
5858 // / CRTP helper method
5959 inline Derived& derived () { return *static_cast <Derived*>(this ); }
6060
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)
6363 : _data(data)
6464 {
6565 }
@@ -68,7 +68,7 @@ struct ObservationsAdaptator
6868 inline size_t kdtree_get_point_count () const { return _data.size (); }
6969
7070 // 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); }
7272
7373 // Optional bounding-box computation: return false to default to a standard bbox computation loop.
7474 // 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
191191 inline double worstDist () const { return _radius_sq; }
192192};
193193
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+
194218bool filterLandmarks (SfMData& sfmData, double radiusScale, bool useFeatureScale, int minNbObservationsPerLandmark)
195219{
196220 const auto initialNbLandmarks = sfmData.getLandmarks ().size ();
@@ -648,7 +672,7 @@ bool filterObservations2D(SfMData& sfmData, int nbNeighbors2D, float percentile,
648672 std::advance (itView, i);
649673 const IndexT viewId = *itView;
650674
651- auto & observationsIt = observationsPerView.find (viewId);
675+ auto observationsIt = observationsPerView.find (viewId);
652676 if (observationsIt == observationsPerView.end ())
653677 continue ;
654678
@@ -669,7 +693,7 @@ bool filterObservations2D(SfMData& sfmData, int nbNeighbors2D, float percentile,
669693 cacheSize);
670694 for (auto j = 0 ; j < observations.size (); j++)
671695 {
672- const auto & obs = * observations[j];
696+ const auto & obs = observations[j];
673697 std::vector<size_t > indices_ (nbNeighbors_);
674698 std::vector<double > distances_ (nbNeighbors_);
675699 tree.knnSearch (obs.x .data (), nbNeighbors_, &indices_[0 ], &distances_[0 ]);
@@ -694,7 +718,7 @@ bool filterObservations2D(SfMData& sfmData, int nbNeighbors2D, float percentile,
694718 }
695719 estimatedRadii_[i] = radius;
696720
697- std::vector<const Observation* > filteredObservations;
721+ std::vector<Observation> filteredObservations;
698722 std::vector<Landmark*> filteredLandmarks;
699723 filteredObservations.reserve (observations.size ());
700724 filteredLandmarks.reserve (landmarks.size ());
@@ -724,14 +748,14 @@ bool filterObservations2D(SfMData& sfmData, int nbNeighbors2D, float percentile,
724748 if (estimatedRadii_[i] != -1 .)
725749 estimatedRadii[viewId] = estimatedRadii_[i];
726750
727- auto & observationsIt = observationsPerView.find (viewId);
751+ auto observationsIt = observationsPerView.find (viewId);
728752 if (observationsIt != observationsPerView.end ())
729753 {
730754 auto & observations = observationsIt->second .first ;
731755 auto & landmarks = observationsIt->second .second ;
732756 for (int j = 0 ; j < observations.size (); j++)
733757 {
734- landmarks[j]->observations [viewId] = * observations[j];
758+ landmarks[j]->observations [viewId] = observations[j];
735759 }
736760 }
737761 }
@@ -754,7 +778,7 @@ int aliceVision_main(int argc, char *argv[])
754778 double neighborsInfluence = 0.5 ;
755779 int nbIterations = 5 ;
756780 int nbNeighbors2D = 5 ;
757- float percentile = 0.95 ;
781+ float percentile = 0 .95f ;
758782
759783 // user optional parameters
760784 std::vector<std::string> featuresFolders;
0 commit comments