00001 #ifndef rrel_ransac_obj_h_ 00002 #define rrel_ransac_obj_h_ 00003 00004 //: 00005 // \file 00006 // \author Chuck Stewart (stewart@cs.rpi.edu) 00007 // RANSAC objective function. 00008 00009 #include <rrel/rrel_objective.h> 00010 00011 //: The objective function for RANSAC. 00012 // The RANSAC objective function is 0 for residuals whose magnitude 00013 // is less than a threshold, and 1 otherwise. This loss function is 00014 // really here only for historical purposes and should not be used in 00015 // practice. Smooth loss functions should be used. This is shown in 00016 // a practical sense in Torr and Zisserman, CVIU, April 2000 and in a 00017 // theoretical sense in Stewart, PAMI, August 1997. 00018 00019 class rrel_ransac_obj : public rrel_objective { 00020 public: 00021 //: Constructor. 00022 // The threshold is scale_mult*prior_scale, where prior scale is 00023 // supplied by the problem. 00024 rrel_ransac_obj( double scale_mult = 2.0 ); 00025 00026 //: Destructor. 00027 ~rrel_ransac_obj(); 00028 00029 //: Evaluate the objective function on heteroscedastic residuals. 00030 // \sa rrel_objective::fcn. 00031 virtual double fcn( vect_const_iter res_begin, vect_const_iter res_end, 00032 vect_const_iter scale_begin, 00033 vnl_vector<double>* = 0 /* param vector is unused */ ) const; 00034 00035 //: Evaluate the objective function on homoscedastic residuals. 00036 // \sa rrel_objective::fcn. 00037 virtual double fcn( vect_const_iter begin, vect_const_iter end, 00038 double scale, 00039 vnl_vector<double>* = 0 /* param vector is unused */ ) const; 00040 00041 //: True. 00042 // Using a RANSAC objective with an estimated scale doesn't make 00043 // sense, because the any scale estimate tends to be inaccurate and 00044 // RANSAC is sensitive to the threshold (and hence the scale). 00045 virtual bool requires_prior_scale() const 00046 { return true; } 00047 00048 protected: 00049 double scale_mult_; 00050 }; 00051 00052 #endif 00053