1313#include < aliceVision/matching/MatchesCollections.hpp>
1414#include < aliceVision/matchingImageCollection/GeometricFilterMatrix.hpp>
1515#include < aliceVision/system/ProgressDisplay.hpp>
16+ #include < aliceVision/matchingImageCollection/GeometricInfo.hpp>
1617
1718#include < map>
1819#include < random>
@@ -28,7 +29,7 @@ using namespace aliceVision::matching;
2829 * or all the pairs and regions correspondences contained in the putativeMatches set.
2930 * Allow to keep only geometrically coherent matches.
3031 * It discards pairs that do not lead to a valid robust model estimation.
31- * @param[out] geometricMatches
32+ * @param[out] out_geometricMatches
3233 * @param[in] sfmData
3334 * @param[in] regionsPerView
3435 * @param[in] functor
@@ -39,7 +40,7 @@ using namespace aliceVision::matching;
3940 */
4041template <typename GeometryFunctor>
4142void robustModelEstimation (PairwiseMatches& out_geometricMatches,
42- const sfmData::SfMData* sfmData,
43+ const sfmData::SfMData& sfmData,
4344 const feature::RegionsPerView& regionsPerView,
4445 const GeometryFunctor& functor,
4546 const PairwiseMatches& putativeMatches,
@@ -73,7 +74,6 @@ void robustModelEstimation(PairwiseMatches& out_geometricMatches,
7374 {
7475 MatchesPerDescType guidedGeometricInliers;
7576 geometricFilter.Geometry_guided_matching (sfmData, regionsPerView, imagePair, distanceRatio, guidedGeometricInliers);
76- // ALICEVISION_LOG_DEBUG("#before/#after: " << putative_inliers.size() << "/" << guided_geometric_inliers.size());
7777 std::swap (inliers, guidedGeometricInliers);
7878 }
7979
@@ -87,6 +87,64 @@ void robustModelEstimation(PairwiseMatches& out_geometricMatches,
8787 }
8888}
8989
90+ /* *
91+ * @brief Perform robust model estimation (with optional guided_matching)
92+ * or all the pairs and regions correspondences contained in the putativeMatches set.
93+ * Allow to keep only geometrically coherent matches.
94+ * It discards pairs that do not lead to a valid robust model estimation.
95+ * @param[out] out_geometricInfos
96+ * @param[in] sfmData
97+ * @param[in] regionsPerView
98+ * @param[in] functor
99+ * @param[in] putativeMatches
100+ * @param[in] randomNumberGenerator
101+ */
102+ template <typename GeometryFunctor>
103+ void robustModelEstimation (PairwiseGeometricInfo& out_geometricInfos,
104+ const sfmData::SfMData& sfmData,
105+ const feature::RegionsPerView& regionsPerView,
106+ const GeometryFunctor& functor,
107+ const PairwiseMatches& putativeMatches,
108+ std::mt19937& randomNumberGenerator)
109+ {
110+ out_geometricInfos.clear ();
111+
112+ auto progressDisplay = system::createConsoleProgressDisplay (putativeMatches.size (), std::cout, " Robust Model Estimation\n " );
113+
114+ #pragma omp parallel for schedule(dynamic)
115+ for (int i = 0 ; i < (int )putativeMatches.size (); ++i)
116+ {
117+ PairwiseMatches::const_iterator iter = putativeMatches.begin ();
118+ std::advance (iter, i);
119+
120+ const Pair currentPair = iter->first ;
121+ const MatchesPerDescType& putativeMatchesPerType = iter->second ;
122+ const Pair& imagePair = iter->first ;
123+
124+ // apply the geometric filter (robust model estimation)
125+ {
126+ MatchesPerDescType inliers;
127+ GeometryFunctor geometricFilter = functor; // use a copy since we are in a multi-thread context
128+ const EstimationStatus state =
129+ geometricFilter.geometricEstimation (sfmData, regionsPerView, imagePair, putativeMatchesPerType, randomNumberGenerator, inliers);
130+
131+ if (state.hasStrongSupport )
132+ {
133+ #pragma omp critical
134+ {
135+ PairGeometricInfo info;
136+ info.model = geometricFilter.getMatrix ();
137+ info.inliers = inliers.getNbAllMatches ();
138+ info.threshold = geometricFilter.m_dPrecision_robust ;
139+ info.type = geometricFilter.getType ();
140+ out_geometricInfos.emplace (currentPair, info);
141+ }
142+ }
143+ }
144+ ++progressDisplay;
145+ }
146+ }
147+
90148/* *
91149 * @brief removePoorlyOverlappingImagePairs Removes image pairs from the given list of geometric
92150 * matches that have poor overlap according to the supplied criteria.
0 commit comments