2 #ifndef vgl_fit_lines_2d_hxx_ 3 #define vgl_fit_lines_2d_hxx_ 11 # include <vcl_msvc_warnings.h> 20 min_length_ = min_length;
33 std::cout << p <<
'\n';
50 curve_indices_.clear();
56 assert(start_index < curve_.size() && end_index <= curve_.size());
59 std::cout <<
"output " << line <<
'\n';
61 for(
unsigned i=start_index; i<end_index; ++i)
62 curve_indices_[i] = segs_.size();
63 segs_.push_back(line);
69 if (curve_.size()<min_length_)
72 std::cout <<
"In vgl_fit_lines_2d<T>::fit() - " 73 <<
"number of points < min_length " << min_length_ <<
'\n';
77 curve_indices_.clear();
78 curve_indices_.resize(curve_.size(), -1);
83 unsigned int ns = 0, nf = min_length_, cur_len = curve_.size();
84 for (
unsigned int i = ns; i<nf; ++i)
98 bool below_error_tol =
true;
99 bool data_added =
false;
100 while (nf<cur_len&&below_error_tol)
105 below_error_tol = error<tol_;
118 ns = nf-1; nf=ns+min_length_;
122 for (
unsigned int i = ns; i<nf; i++)
153 #undef VGL_FIT_LINES_2D_INSTANTIATE 154 #define VGL_FIT_LINES_2D_INSTANTIATE(T) \ 155 template class vgl_fit_lines_2d<T > 157 #endif // vgl_fit_lines_2d_hxx_ bool fit()
the fitting method.
void clear()
clear internal data.
vgl_fit_lines_2d(unsigned int min_length=10, T tol=0.15)
Constructor.
bool fit()
Fit a line to the current point set.
double get_rms_error_est(vgl_point_2d< T > const &p, bool increment=true)
Get estimated fitting error if the point (x, y) were added to the fit.
unsigned int get_n_pts() const
The number of points added.
A class to hold the line 2d_regression data and actual fitting code.
double get_rms_error(const T a, const T b, const T c)
Get fitting error for a given line.
void increment_partial_sums(const T x, const T y)
Add a point to the 2d_regression.
void init_rms_error_est()
Initialize estimated fitting error.
void clear()
Clear 2d_regression sums.
void decrement_partial_sums(const T x, const T y)
Remove a point from the 2d_regression.
Fits a contiguous set of line segments to a sampled curve.
A helper class for line fitting.
void add_point(vgl_point_2d< T > const &p)
add a point to the curve.
void output(unsigned int start_index, unsigned int end_index)
output a line that fits from start to end.