Skip to content

Commit

Permalink
- Code cleanup on robust_estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
rperrot committed Apr 19, 2016
1 parent dfb460f commit c17600c
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/openMVG/robust_estimation/guided_matching.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,8 @@ void GuidedMatching_Fundamental_Fast(
itBs != buckets.begin() + bucket_stop; ++itBs)
{
const Bucket_vec & bucket = *itBs;
for(Bucket_vec::const_iterator itB = bucket.begin(); itB != bucket.end(); ++itB)
for( const auto & i : bucket )
{
const IndexT i = *itB;
// Compute descriptor distance
const double descDist = lRegions.SquaredDescriptorDistance(i, &rRegions, j);
// Update the corresponding points & distance (if required)
Expand Down
3 changes: 2 additions & 1 deletion src/openMVG/robust_estimation/rand_sampling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
namespace openMVG {
namespace robust{

// rperrot : is this legal ? why using an anonymous namespace here ?
namespace
{
std::default_random_engine random_generator;
}
} //

/**
* Pick a random subset of the integers [0, total), in random order.
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/robust_estimation/robust_estimator_ACRansac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
namespace openMVG {
namespace robust{

namespace acrancac_nfa_internal {
namespace acransac_nfa_internal {

/// logarithm (base 10) of binomial coefficient
template <typename T>
Expand Down Expand Up @@ -368,7 +368,7 @@ std::pair<double, double> ACRANSAC(const Kernel &kernel,

// Initialize the NFA computation interface
// (quantified NFA computation is used if a valid upper bound is provided)
acrancac_nfa_internal::NFA_Interface<Kernel> nfa_interface
acransac_nfa_internal::NFA_Interface<Kernel> nfa_interface
(kernel, maxThreshold, (precision!=std::numeric_limits<double>::infinity()));

// Output parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
// by the generic ACRANSAC routine.
//

#include "openMVG/numeric/numeric.h"

namespace openMVG {
namespace robust{

Expand Down
6 changes: 3 additions & 3 deletions src/openMVG/robust_estimation/robust_estimator_LMeds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace robust{
/// IJCV 1998
template <typename Kernel>
double LeastMedianOfSquares(const Kernel &kernel,
typename Kernel::Model * model = NULL,
double* outlierThreshold = NULL,
typename Kernel::Model * model = nullptr ,
double* outlierThreshold = nullptr ,
double outlierRatio=0.5,
double minProba=0.99)
{
Expand Down Expand Up @@ -63,7 +63,7 @@ template <typename Kernel>
}

// Compute median
std::vector<double>::iterator itMedian = residuals.begin() +
auto itMedian = residuals.begin() +
std::size_t( total_samples*(1.-outlierRatio) );
std::nth_element(residuals.begin(), itMedian, residuals.end());
double median = *itMedian;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace robust{
template<typename Kernel, typename Scorer>
typename Kernel::Model MaxConsensus(const Kernel &kernel,
const Scorer &scorer,
std::vector<size_t> *best_inliers = NULL, size_t max_iteration = 1024) {
std::vector<size_t> *best_inliers = nullptr , size_t max_iteration = 1024) {

const size_t min_samples = Kernel::MINIMUM_SAMPLES;
const size_t total_samples = kernel.NumSamples();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ TEST(MaxConsensusLineFitter, RealisticCase) {

//-- Add some noise (for the asked percentage amount)
int nbPtToNoise = (int) NbPoints*inlierPourcentAmount/100.0;
vector<size_t> vec_samples; // Fit with unique random index
std::vector<size_t> vec_samples; // Fit with unique random index
UniformSample(nbPtToNoise, NbPoints, &vec_samples);
for(size_t i = 0; i <vec_samples.size(); ++i)
{
Expand Down
5 changes: 3 additions & 2 deletions src/openMVG/robust_estimation/robust_estimator_Ransac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <limits>
#include <numeric>
#include <vector>
#include <cassert>

namespace openMVG {
namespace robust{
Expand All @@ -33,8 +34,8 @@ template<typename Kernel, typename Scorer>
typename Kernel::Model RANSAC(
const Kernel &kernel,
const Scorer &scorer,
std::vector<size_t> *best_inliers = NULL,
double *best_score = NULL,
std::vector<size_t> *best_inliers = nullptr ,
double *best_score = nullptr ,
double outliers_probability = 1e-2)
{
assert(outliers_probability < 1.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ TEST(MaxConsensusLineFitter, RealisticCase) {

//-- Add some noise (for the asked percentage amount)
int nbPtToNoise = (int) NbPoints*inlierPourcentAmount/100.0;
vector<size_t> vec_samples; // Fit with unique random index
std::vector<size_t> vec_samples; // Fit with unique random index
UniformSample(nbPtToNoise, NbPoints, &vec_samples);
for(size_t i = 0; i <vec_samples.size(); ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/robust_estimation/score_evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#ifndef OPENMVG_ROBUST_ESTIMATION_SCORE_EVALUATOR_H_
#define OPENMVG_ROBUST_ESTIMATION_SCORE_EVALUATOR_H_

#include <vector>

namespace openMVG {
namespace robust{

using namespace std;

/// Templated Functor class to evaluate a given model over a set of samples.
template<typename Kernel>
class ScorerEvaluator {
Expand Down

0 comments on commit c17600c

Please sign in to comment.