00001 #ifndef mfpf_sad_vec_cost_builder_h_ 00002 #define mfpf_sad_vec_cost_builder_h_ 00003 //: 00004 // \file 00005 // \brief Builder for mfpf_sad_vec_cost objects. 00006 // \author Tim Cootes 00007 00008 #include <mfpf/mfpf_vec_cost_builder.h> 00009 #include <vnl/vnl_vector.h> 00010 #include <vcl_iosfwd.h> 00011 #include <vcl_vector.h> 00012 00013 //: Builder for mfpf_sad_vec_cost objects. 00014 class mfpf_sad_vec_cost_builder : public mfpf_vec_cost_builder 00015 { 00016 private: 00017 //: Minimum mean abs diff allowed 00018 double min_mad_; 00019 00020 //: Space to record examples 00021 vcl_vector<vnl_vector<double> > data_; 00022 00023 //: If true recalculate min_mad_ based on median of training set 00024 bool impose_robust_min_mad_; 00025 00026 //: Define default values 00027 void set_defaults(); 00028 public: 00029 00030 // Dflt ctor 00031 mfpf_sad_vec_cost_builder(); 00032 00033 // Destructor 00034 virtual ~mfpf_sad_vec_cost_builder(); 00035 00036 00037 //: Create new mfpf_sad_vec_cost on heap 00038 virtual mfpf_vec_cost* new_cost() const; 00039 00040 //: Initialise building 00041 // Must be called before any calls to add_example(...) 00042 virtual void clear(unsigned n_egs); 00043 00044 //: Add one example to the model 00045 virtual void add_example(const vnl_vector<double>& v); 00046 00047 //: Build object from the data supplied in add_example() 00048 virtual void build(mfpf_vec_cost&); 00049 00050 //: Initialise from a string stream 00051 virtual bool set_from_stream(vcl_istream &is); 00052 00053 //: Set flag for robust min mad (based on training set) 00054 void set_impose_robust_min_mad(bool on) {impose_robust_min_mad_=on;} 00055 00056 //: Name of the class 00057 virtual vcl_string is_a() const; 00058 00059 //: Create a copy on the heap and return base class pointer 00060 virtual mfpf_vec_cost_builder* clone() const; 00061 00062 //: Print class to os 00063 virtual void print_summary(vcl_ostream& os) const; 00064 00065 //: Version number for I/O 00066 short version_no() const; 00067 00068 //: Save class to binary file stream 00069 virtual void b_write(vsl_b_ostream& bfs) const; 00070 00071 //: Load class from binary file stream 00072 virtual void b_read(vsl_b_istream& bfs); 00073 }; 00074 00075 #endif // mfpf_sad_vec_cost_builder_h_