Skip to content

Commit

Permalink
- code cleanup on matching
Browse files Browse the repository at this point in the history
- fix override on linearProgramming
  • Loading branch information
rperrot committed Apr 19, 2016
1 parent b952cf9 commit c056631
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/openMVG/linearProgramming/linearProgrammingOSI_X.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public :

bool solve() override ;

bool getSolution(std::vector<double> & estimatedParams);
bool getSolution(std::vector<double> & estimatedParams) override;

private :
SOLVERINTERFACE *si;
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/matching/indMatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ typedef std::map< Pair, IndMatches > PairWiseMatches;
static Pair_Set getPairs(const PairWiseMatches & matches)
{
Pair_Set pairs;
for(PairWiseMatches::const_iterator it = matches.begin(); it != matches.end(); ++it)
pairs.insert(it->first);
for( const auto & cur_pair : matches )
pairs.insert(cur_pair.first);
return pairs;
}

Expand Down
37 changes: 25 additions & 12 deletions src/openMVG/matching/indMatchDecoratorXY.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ class IndMatchDecorator
const std::vector<features::SIOPointFeature> & rightFeat)
:_vec_matches(vec_matches)
{
for (size_t i = 0; i < vec_matches.size(); ++i) {
const size_t I = vec_matches[i]._i;
const size_t J = vec_matches[i]._j;
for ( const auto & cur_vec_match : vec_matches ) // size_t i = 0; i < vec_matches.size(); ++i)
{
const size_t I = cur_vec_match._i ;
const size_t J = cur_vec_match._j ;

// const size_t I = vec_matches[i]._i;
// const size_t J = vec_matches[i]._j;
_vecDecoredMatches.push_back(
IndMatchDecoratorStruct(leftFeat[I].x(),leftFeat[I].y(),
rightFeat[J].x(), rightFeat[J].y(), vec_matches[i]));
rightFeat[J].x(), rightFeat[J].y(), cur_vec_match ) );
}
}

Expand All @@ -78,12 +82,16 @@ class IndMatchDecorator
const std::vector<features::PointFeature> & rightFeat)
:_vec_matches(vec_matches)
{
for (size_t i = 0; i < vec_matches.size(); ++i) {
const size_t I = vec_matches[i]._i;
const size_t J = vec_matches[i]._j;
for ( const auto & cur_vec_match : vec_matches )
{
// size_t i = 0; i < vec_matches.size(); ++i) {
const size_t I = cur_vec_match._i ;
const size_t J = cur_vec_match._j ;
// const size_t I = vec_matches[i]._i;
// const size_t J = vec_matches[i]._j;
_vecDecoredMatches.push_back(
IndMatchDecoratorStruct(leftFeat[I].x(),leftFeat[I].y(),
rightFeat[J].x(), rightFeat[J].y(), vec_matches[i]));
rightFeat[J].x(), rightFeat[J].y(), cur_vec_match ) );
}
}

Expand All @@ -92,12 +100,17 @@ class IndMatchDecorator
const Mat & rightFeat)
:_vec_matches(vec_matches)
{
for (size_t i = 0; i < vec_matches.size(); ++i) {
const size_t I = vec_matches[i]._i;
const size_t J = vec_matches[i]._j;
for ( const auto & cur_vec_match : vec_matches )
{
//size_t i = 0; i < vec_matches.size(); ++i) {
const size_t I = cur_vec_match._i ;
const size_t J = cur_vec_match._j ;

// const size_t I = vec_matches[i]._i;
// const size_t J = vec_matches[i]._j;
_vecDecoredMatches.push_back(
IndMatchDecoratorStruct(leftFeat.col(I)(0),leftFeat.col(I)(1),
rightFeat.col(J)(0), rightFeat.col(J)(1), vec_matches[i]));
rightFeat.col(J)(0), rightFeat.col(J)(1), cur_vec_match ) ) ;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/openMVG/matching/indMatch_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ static bool Save
{
return false;
}
for (PairWiseMatches::const_iterator iter = matches.begin();
iter != matches.end(); ++iter)
for ( const auto & cur_match : matches )
{
const size_t I = iter->first.first;
const size_t J = iter->first.second;
const std::vector<IndMatch> & pair_matches = iter->second;
const size_t I = cur_match.first.first ;
const size_t J = cur_match.first.second ;

const std::vector<IndMatch> & pair_matches = cur_match.second ;
stream << I << " " << J << '\n' << pair_matches.size() << '\n';
copy(pair_matches.begin(), pair_matches.end(),
std::ostream_iterator<IndMatch>(stream, "\n"));
Expand Down
2 changes: 1 addition & 1 deletion src/openMVG/matching/matcher_brute_force.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ArrayMatcherBruteForce : public ArrayMatcher<Scalar, Metric>
public:
typedef typename Metric::ResultType DistanceType;

ArrayMatcherBruteForce() {}
ArrayMatcherBruteForce() = default ;
virtual ~ArrayMatcherBruteForce() {
memMapping.reset();
}
Expand Down
2 changes: 1 addition & 1 deletion src/openMVG/matching/matcher_cascade_hashing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ArrayMatcherCascadeHashing : public ArrayMatcher<Scalar, Metric>
public:
typedef typename Metric::ResultType DistanceType;

ArrayMatcherCascadeHashing() {}
ArrayMatcherCascadeHashing() = default ;
virtual ~ArrayMatcherCascadeHashing() {
memMapping.reset();
}
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/matching/matcher_kdtree_flann.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ArrayMatcher_Kdtree_Flann : public ArrayMatcher<Scalar, Metric>
public:
typedef typename Metric::ResultType DistanceType;

ArrayMatcher_Kdtree_Flann() {}
ArrayMatcher_Kdtree_Flann() = default ;

virtual ~ArrayMatcher_Kdtree_Flann() {
_datasetM.reset();
Expand Down Expand Up @@ -134,7 +134,7 @@ class ArrayMatcher_Kdtree_Flann : public ArrayMatcher<Scalar, Metric>
{
for (size_t j = 0; j < NN; ++j)
{
if (indices[i] > 0)
if (indices[i] > 0) // rperrot : nullptr here ?
{
pvec_indices->emplace_back(IndMatch(i, vec_indices[i*NN+j]));
pvec_distances->emplace_back(vec_distances[i*NN+j]);
Expand Down
2 changes: 1 addition & 1 deletion src/openMVG/matching/matching_filters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static void Filter( int NN,
// Remove multi-index
{
std::sort(vec_outIndex.begin(), vec_outIndex.end());
std::vector<IndMatch>::iterator end = std::unique(vec_outIndex.begin(), vec_outIndex.end());
auto end = std::unique(vec_outIndex.begin(), vec_outIndex.end());
if(end != vec_outIndex.end()) {
vec_outIndex.erase(end, vec_outIndex.end());
}
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/matching/matching_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class ArrayMatcher
typedef typename Metric::ResultType DistanceType;
typedef Metric MetricT;

ArrayMatcher() {}
virtual ~ArrayMatcher() {};
ArrayMatcher() = default ;
virtual ~ArrayMatcher() = default ;

/**
* Build the matching structure
Expand Down
5 changes: 2 additions & 3 deletions src/openMVG/matching/pairwiseAdjacencyDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ void PairWiseMatchingToAdjacencyMatrixSVG(const size_t NbImages,
for (size_t I = 0; I < NbImages; ++I) {
for (size_t J = 0; J < NbImages; ++J) {
// If the pair have matches display a blue boxes at I,J position.
matching::PairWiseMatches::const_iterator iterSearch =
map_Matches.find(std::make_pair(I,J));
auto iterSearch = map_Matches.find(std::make_pair(I,J));
if (iterSearch != map_Matches.end() && !iterSearch->second.empty())
{
// Display as a tooltip: (IndexI, IndexJ NbMatches)
Expand All @@ -42,7 +41,7 @@ void PairWiseMatchingToAdjacencyMatrixSVG(const size_t NbImages,
}
}
// Display axes with 0 -> NbImages annotation : _|
std::ostringstream osNbImages;
std::ostringstream osNbImages;
osNbImages << NbImages;
svgStream.drawText((NbImages+1)*scaleFactor, scaleFactor, scaleFactor, "0", "black");
svgStream.drawText((NbImages+1)*scaleFactor,
Expand Down
12 changes: 6 additions & 6 deletions src/openMVG/matching/regions_matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void DistanceRatioMatch
class RegionsMatcher
{
public:
~RegionsMatcher() {}
~RegionsMatcher() = default ;

/**
* @brief Initialize the retrieval database
Expand Down Expand Up @@ -103,7 +103,7 @@ class RegionsMatcherT : public RegionsMatcher
typedef typename ArrayMatcherT::ScalarT Scalar;
typedef typename ArrayMatcherT::DistanceType DistanceType;

RegionsMatcherT() :regions_(NULL) {}
RegionsMatcherT() :regions_(nullptr) {}

/**
* @brief Init the matcher with some reference regions.
Expand All @@ -121,7 +121,7 @@ class RegionsMatcherT : public RegionsMatcher
void Init_database
(
const features::Regions& regions
)
) override
{
regions_ = &regions;
if (regions_->RegionCount() == 0)
Expand All @@ -137,7 +137,7 @@ class RegionsMatcherT : public RegionsMatcher
bool Match(
const float f_dist_ratio,
const features::Regions& queryregions_,
matching::IndMatches & vec_putative_matches)
matching::IndMatches & vec_putative_matches) override
{
if (regions_ == nullptr)
return false;
Expand Down Expand Up @@ -165,9 +165,9 @@ class RegionsMatcherT : public RegionsMatcher
b_squared_metric_ ? Square(f_dist_ratio) : f_dist_ratio);

vec_putative_matches.reserve(vec_nn_ratio_idx.size());
for (size_t k=0; k < vec_nn_ratio_idx.size(); ++k)
for ( const auto & index : vec_nn_ratio_idx ) // size_t k=0; k < vec_nn_ratio_idx.size(); ++k)
{
const size_t index = vec_nn_ratio_idx[k];
// const size_t index = vec_nn_ratio_idx[k];
vec_putative_matches.emplace_back(vec_nIndice[index*NNN__]._j, vec_nIndice[index*NNN__]._i);
}

Expand Down

0 comments on commit c056631

Please sign in to comment.