contrib/rpl/rgrl/rgrl_matcher_k_nearest_pick_one.h
Go to the documentation of this file.
00001 #ifndef rgrl_matcher_k_nearest_pick_one_h_
00002 #define rgrl_matcher_k_nearest_pick_one_h_
00003 //:
00004 // \file
00005 // \author Gehua Yang
00006 // \date   March 2005
00007 // \verbatim
00008 //  Modifications
00009 //   Gehua Yang - Dec 2006 - change the base class to rgrl_matcher_k_nearest_adv. 
00010 //     This is to allow reuse of the old matches when the mapping difference 
00011 //     is smaller than a threshold.
00012 // \endverbatim
00013 
00014 #include <rgrl/rgrl_matcher_k_nearest_adv.h>
00015 
00016 //: For each "from" feature, match the k nearest "to" features.
00017 //
00018 // This will map the "from" feature via the current transform and
00019 // select the k nearest "to" features to the mapped "from" feature.
00020 //
00021 // The some of the nearest features can optionally be discarded if it
00022 // is further than some threshold distance.
00023 //
00024 class rgrl_matcher_k_nearest_pick_one
00025   : public rgrl_matcher_k_nearest_adv
00026 {
00027  public:
00028   //: Initialize the matcher to select \a k correspondences per "from" feature.
00029   //
00030   rgrl_matcher_k_nearest_pick_one( unsigned int k );
00031 
00032   //: Select at most \a k correspondences within the threshold.
00033   //
00034   // The matcher will select \a k correspondences from the list of
00035   // correspondences with Euclidean distance within the threshold
00036   // \a dist_thres.
00037   //
00038   rgrl_matcher_k_nearest_pick_one( unsigned int k, double dist_thres, double min_mapped_scale = -1, double thres_reuse_match = -1 );
00039 
00040   rgrl_match_set_sptr
00041   compute_matches( rgrl_feature_set const&       from_features,
00042                    rgrl_feature_set const&       to_features,
00043                    rgrl_view const&              current_view,
00044                    rgrl_transformation const&    current_xform,
00045                    rgrl_scale const&             /* current_scale */,
00046                    rgrl_match_set_sptr const& old_matches = 0 );
00047 
00048 
00049   // Defines type-related functions
00050   rgrl_type_macro( rgrl_matcher_k_nearest_pick_one, rgrl_matcher);
00051 
00052  protected:
00053 
00054   //: validate the mapped feature
00055   inline
00056   bool validate( rgrl_feature_sptr const& mapped, rgrl_mask_sptr const& roi_sptr ) const;
00057 
00058   //: This is internal to invert matches function.
00059   //  It is to restrict the number of nearest neighbors
00060   virtual
00061   void
00062   add_one_flipped_match( rgrl_match_set_sptr&      inv_set,
00063                          rgrl_view          const& current_view,
00064                          nodes_vec_iterator const& begin_iter,
00065                          nodes_vec_iterator const& end_iter ); 
00066  
00067 };
00068 
00069 #endif // rgrl_matcher_k_nearest_pick_one_h_