00001 // This is gel/vdgl/vdgl_fit_lines.h 00002 #ifndef vdgl_fit_lines_h_ 00003 #define vdgl_fit_lines_h_ 00004 //--------------------------------------------------------------------- 00005 //: 00006 // \file 00007 // \brief a processor for fitting line segments to digital curves 00008 // 00009 // This line fitting algorithm is based on the original Charlie Rothwell 00010 // detector as ported by FSM in osl. This version does incremental 00011 // fitting to a chain of points (given as a digital curve) and produces a 00012 // vcl_vector<vsol_line_2d_sptr>. The actual fitting algorithm is 00013 // in vgl/algo and therefore should be of wider applicability. 00014 // 00015 // \author 00016 // J.L. Mundy - April 10, 2003 00017 // 00018 // \verbatim 00019 // Modifications 00020 // May 2004 - Peter Vanroose - ported from sdet; removed dependency on vtol 00021 // \endverbatim 00022 // 00023 //------------------------------------------------------------------------- 00024 #include <vcl_vector.h> 00025 #include <vgl/algo/vgl_fit_lines_2d.h> 00026 #include <vsol/vsol_line_2d_sptr.h> 00027 #include <vdgl/vdgl_digital_curve_sptr.h> 00028 #include <vdgl/vdgl_fit_lines_params.h> 00029 00030 class vdgl_fit_lines : public vdgl_fit_lines_params 00031 { 00032 // members 00033 vcl_vector<vdgl_digital_curve_sptr> curves_; //!< the input curves 00034 vcl_vector<vsol_line_2d_sptr> line_segs_; //!< the output lines 00035 vgl_fit_lines_2d<double> fitter_; //!< the fitting class 00036 public: 00037 //: constructor from a parameter block (the only way) 00038 vdgl_fit_lines(vdgl_fit_lines_params& flp) 00039 : vdgl_fit_lines_params(flp), fitter_(vgl_fit_lines_2d<double>()) {} 00040 00041 ~vdgl_fit_lines() {} 00042 00043 //: Set the curves to be processed 00044 void set_curves(vcl_vector<vdgl_digital_curve_sptr> const& curves) { line_segs_.clear(); curves_=curves; } 00045 //: Return the line segments 00046 vcl_vector<vsol_line_2d_sptr>& get_line_segs() { fit_lines(); return line_segs_; } 00047 //: Clear the internal storage 00048 void clear() { fitter_.clear(); curves_.clear(); line_segs_.clear(); } 00049 00050 protected: 00051 //: Actual process method 00052 bool fit_lines(); 00053 //: default constructor cannot be used 00054 vdgl_fit_lines(); 00055 }; 00056 00057 #endif // vdgl_fit_lines_h_