Data structure

class DMatch

This is the data structure that is used to store the matching features

  • vector<pair<int, int> > ind_key_ stores the index of the mathcing features
  • float dist_ stores the distance of the matching features

Parameters

class Match_Param

This is the class that stores the parameters of the matchers, the first two are used by all matchers.

  • ratio is the distance ratio of best matching features w.r.t the second-best matching features;
  • nmatches_min_ guarantees that number of returned matches is no less than the specified value;
  • ndims, leaf_max_size are used by nanoflann for KD-tree construction;
  • nresults specifies the number of returned matching features for each search.

Matcher

class Matcher

This is the base class for all matching algorithms. There are three pure virtual methods that must be implemented in the sub-classes.

virtual void init_param(Matcher_Param r_matcher_param) = 0;

method to initialize the parameter.

virtual int match(const std::vector<Vecf>& desc1, const std::vector<Vecf>& desc2, std::vector<DMatch>& matches) = 0;
virtual int match(const std::vector<Vecf>& desc1, const std::vector<Vecf>& desc2, std::vector<DMatch>& matches, float (*dist_metric)(const Vecf& desc1, const Vecf& desc2)) = 0;

methods that are responsible for feature matching.

Distance metrics

distance.h

There are multiple distance metrics implemented, currently l1-norm and l2-norm. These distance metrices is passed to the match method via a function pointer. This mechanism provides greate flexibility to developers as it allows the user to implement their own distance metrics without change the code within the match method. The function pointer has the form of

float (*dist_metric)(const Vecf& desc1, const Vecf& desc2);

Brute-force matcher

class Matcher_Brute_Force

This class implements the simple, yet inefficient brute-force feature matching algorithm.

Flann matcher

class Matcher_Flann

This class implements the bidirectional matching using nanoflann for fast nearest neighbor search.

int match(const std::vector<Vecf>& desc1, const std::vector<Vecf>& desc2, std::vector<DMatch>& matches);

method that invokes the match_bidirect method with varying ratio value. The ratio value are automatically adjusted to return no less than nmatches_min_ matching features.

int match_bidirect(const std::vector<Vecf>& desc1, const std::vector<Vecf>& desc2, const kd_tree_t& kd_tree_1, const kd_tree_t& kd_tree_2, const float ratio, std::vector<DMatch>& matches);

method that performs bi-directional matching.