contrib/rpl/rgrl/rgrl_convergence_tester.h
Go to the documentation of this file.
00001 #ifndef rgrl_convergence_tester_h_
00002 #define rgrl_convergence_tester_h_
00003 //:
00004 // \file
00005 #include "rgrl_set_of.h"
00006 #include "rgrl_match_set_sptr.h"
00007 #include "rgrl_scale_sptr.h"
00008 #include "rgrl_converge_status_sptr.h"
00009 #include "rgrl_transformation_sptr.h"
00010 #include "rgrl_estimator_sptr.h"
00011 #include "rgrl_mask.h"
00012 #include "rgrl_object.h"
00013 
00014 class rgrl_view;
00015 class rgrl_transformation;
00016 
00017 class rgrl_convergence_tester
00018   : public rgrl_object
00019 {
00020  public:
00021 
00022   //: ctor
00023   rgrl_convergence_tester() : rel_tol_thres_(1e-3) { }
00024 
00025   virtual ~rgrl_convergence_tester();
00026 
00027   //:  Compute the converge_status of the current view using multiple match sets
00028   //   This is the pure virtual function implemented in the derived classes.
00029   //
00030   virtual rgrl_converge_status_sptr
00031   compute_status( rgrl_converge_status_sptr               prev_status,
00032                   rgrl_view                        const& prev_view,
00033                   rgrl_view                        const& current_view,
00034                   rgrl_set_of<rgrl_match_set_sptr> const& current_match_sets,
00035                   rgrl_set_of<rgrl_scale_sptr>     const& current_scales,
00036                   bool                                    penalize_scaling = false )const  = 0;
00037 
00038   //:  Compute the converge_status of the current view using single match set
00039   //
00040   //   Matches are assumed to have from_feature mapped and stored and
00041   //   associated weights computed already when passed to this function.
00042   rgrl_converge_status_sptr
00043   compute_status( rgrl_converge_status_sptr               prev_status,
00044                   rgrl_view                        const& prev_view,
00045                   rgrl_view                        const& current_view,
00046                   rgrl_match_set_sptr                     current_match_set,
00047                   rgrl_scale_sptr                         current_scale,
00048                   bool                                    penalize_scaling = false)const;
00049 
00050   //:  Compute the converge_status of the current xform estimate using multiple match sets
00051   rgrl_converge_status_sptr
00052   compute_status( rgrl_converge_status_sptr               prev_status,
00053                   rgrl_transformation_sptr                xform_estimate,
00054                   rgrl_estimator_sptr                     xform_estimator,
00055                   rgrl_set_of<rgrl_match_set_sptr> const& current_match_sets,
00056                   rgrl_set_of<rgrl_scale_sptr>     const& current_scales,
00057                   bool                                    penalize_scaling = false)const;
00058   //:  Compute the converge_status of the current xform estimate using single match set
00059   rgrl_converge_status_sptr
00060   compute_status( rgrl_converge_status_sptr               prev_status,
00061                   rgrl_transformation_sptr                xform_estimate,
00062                   rgrl_estimator_sptr                     xform_estimator,
00063                   rgrl_match_set_sptr                     current_match_set,
00064                   rgrl_scale_sptr                         current_scale,
00065                   bool                                    penalize_scaling = false)const;
00066 
00067   //: convenient function for initializing status
00068   rgrl_converge_status_sptr
00069   initialize_status( rgrl_view       const& init_view,
00070                      rgrl_scale_sptr const& prior_scale,
00071                      bool                   penalize_scaling ) const;
00072 
00073   //: convenient function for initializing status
00074   rgrl_converge_status_sptr
00075   initialize_status( rgrl_transformation_sptr                xform_estimate,
00076                      rgrl_estimator_sptr                     xform_estimator,
00077                      rgrl_scale_sptr                  const& prior_scale,
00078                      bool                                    penalize_scaling )const;
00079 
00080 
00081   //: verify the final alignment
00082   virtual
00083   rgrl_converge_status_sptr
00084   verify( rgrl_view                        const& view,
00085           rgrl_set_of<rgrl_match_set_sptr> const& current_match_sets,
00086           rgrl_set_of<rgrl_scale_sptr>     const& current_scales )const;
00087 
00088   rgrl_converge_status_sptr
00089   verify( rgrl_view                   const& view,
00090           rgrl_match_set_sptr         const& current_match_sets,
00091           rgrl_scale_sptr             const& current_scales )const;
00092 
00093   //: set relative tolerance on convergence
00094   void set_rel_tol( double rel_tol )
00095   { rel_tol_thres_ = rel_tol; }
00096 
00097   double rel_tol() const
00098   { return rel_tol_thres_; }
00099 
00100   // Defines type-related functions
00101   rgrl_type_macro( rgrl_convergence_tester, rgrl_object );
00102 
00103  protected:
00104 
00105   //: the real init status function
00106   virtual rgrl_converge_status_sptr
00107   init_status( rgrl_view       const& init_view,
00108                rgrl_scale_sptr const& prior_scale,
00109                bool                   penalize_scaling ) const;
00110 
00111   //:  helper function for computing status
00112   virtual
00113   rgrl_converge_status_sptr
00114   compute_status_helper(double new_error,
00115                         bool   good_enough,
00116                         rgrl_converge_status_sptr               prev_status,
00117                         rgrl_view                        const& prev_view,
00118                         rgrl_view                        const& current_view ) const;
00119 
00120  protected:
00121   double  rel_tol_thres_;
00122 };
00123 
00124 #endif