Skip to content

Commit

Permalink
[samples] Update main_repeatability
Browse files Browse the repository at this point in the history
- Add parallelism in guided matching
- Add export to CSV of feature repeatability as it was done for feat+desc
  • Loading branch information
pmoulon committed Mar 25, 2021
1 parent 15197eb commit 016b330
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/openMVG/robust_estimation/guided_matching.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ void GuidedMatching(
// Looking for the corresponding points that have
// the smallest distance (smaller than the provided Threshold)

for (size_t i = 0; i < xLeft.cols(); ++i) {
#pragma omp parallel for
for (int i = 0; i < xLeft.cols(); ++i) {

double min = std::numeric_limits<double>::max();
matching::IndMatch match;
Expand All @@ -57,6 +58,7 @@ void GuidedMatching(
}
if (min < errorTh) {
// save the best corresponding index
#pragma omp critical
vec_corresponding_index.push_back(match);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ int main(int argc, char **argv)
// Evaluate the feature positions accuracy (descriptors are ignored)
if (bFeature_Repeatability)
{
RepeatabilityResults_Matching image_results;
for (size_t i = 1; i < dataset.size(); ++i)
{
if (map_regions.count(0) == 0 || map_regions.count(i) == 0)
Expand All @@ -345,7 +346,7 @@ int main(int argc, char **argv)
const Regions * regions_I = map_regions[i].get();
const PointFeatures pointsFeatures0 = regions_0->GetRegionsPositions();
const PointFeatures pointsFeaturesI = regions_I->GetRegionsPositions();

Mat x0, xI;
PointsToMat(pointsFeatures0, x0);
PointsToMat(pointsFeaturesI, xI);
Expand All @@ -355,14 +356,23 @@ int main(int argc, char **argv)
<Mat3, openMVG::homography::kernel::AsymmetricError>(
dataset.H(i).transpose(), x0, xI, Square(m_dPrecision_robust), matches_0I);

std::cout << "Feature repeatablity Results" << "\n"
std::cout << "Feature repeatability Results" << "\n"
<< "*******************************" << "\n"
<< "# Keypoints 1: \t" << map_regions[0]->RegionCount() << "\n"
<< "# Keypoints N: \t" << map_regions[i]->RegionCount() << "\n"
<< "# Inliers: \t" << matches_0I.size() << "\n"
<< "Inliers Ratio (%): \t" << matches_0I.size() / (float) map_regions[0]->RegionCount() << "\n"
<< std::endl;

const std::vector<double> results = {
static_cast<double>( map_regions[0]->RegionCount() ) ,
static_cast<double>( map_regions[i]->RegionCount() ) ,
static_cast<double>( matches_0I.size() ) ,
static_cast<double>( matches_0I.size() / (float) map_regions[0]->RegionCount())
};
image_results.results[std::to_string(i)] = results;
}
image_results.exportToFile("repeatability_results.xls", stlplus::basename_part(sPath));
}

if (bMatching_Repeatability)
Expand Down

0 comments on commit 016b330

Please sign in to comment.