2 #ifndef vgl_fit_conics_2d_hxx_ 3 #define vgl_fit_conics_2d_hxx_ 12 # include <vcl_msvc_warnings.h> 21 : min_length_(min_length), tol_(tol)
33 std::cout << p <<
'\n';
54 const unsigned end_index,
57 assert(start_index < curve_.size() && end_index <= curve_.size());
60 if (center.ideal(static_cast<T>(1e-06)))
62 std::cout <<
"Can't output a conic at infinity in vgl_fit_conics<T>\n";
69 int middle_index = (end_index-1-start_index)/2 + start_index;
70 if (middle_index == static_cast<int>(start_index))
71 middle_index = end_index-1;
82 unsigned i1=start_index, i2 = end_index-1;
93 std::cout <<
"output " << e_seg <<
'\n';
95 segs_.push_back(e_seg);
101 if (curve_.size()<min_length_)
103 std::cout <<
"In vgl_fit_conics_2d<T>::fit() - number of points < min_length " 104 << min_length_ <<
'\n';
112 unsigned int ns = 0, nf = min_length_, cur_len = curve_.size();
113 for (
unsigned int i = ns; i<nf; ++i)
122 output(ns, nf, reg.
conic());
127 <<
" for\n" << reg.
conic() <<
'\n';
129 bool below_error_tol =
true;
130 bool data_added =
false;
131 while (nf<cur_len&&below_error_tol)
136 below_error_tol = error<tol_;
143 std::cout <<
"Adding point " << p <<
"with estimated error " 152 output(ns, nf, reg.
conic());
153 ns = nf-1; nf=ns+min_length_;
157 for (
unsigned int i = ns; i<nf; i++)
188 #undef VGL_FIT_CONICS_2D_INSTANTIATE 189 #define VGL_FIT_CONICS_2D_INSTANTIATE(T) \ 190 template class vgl_fit_conics_2d<T > 192 #endif // vgl_fit_conics_2d_hxx_ void remove_point(vgl_point_2d< T > const &p)
void output(const unsigned start_index, const unsigned end_index, vgl_conic< T > const &conic)
output a conic that fits from start to end.
vgl_fit_conics_2d(const unsigned min_length=10, const T tol=0.01)
Constructor.
Direction vector in Euclidean 2D space, templated by type of element.
void add_point(vgl_point_2d< T > const &p)
T get_rms_sampson_error() const
get the current Euclidean fitting error in the original frame.
unsigned get_n_pts() const
Number of regression points.
vgl_conic< T > conic() const
T get_rms_error_est(vgl_point_2d< T > const &p) const
get the estimated Euclidean error with respect to the fitted conic segment in the original frame.
void clear_points()
clear the regression data.
bool fit()
the fitting method.
vgl_homg_point_2d< T > centre() const
Returns the centre of the conic, or its point at infinity if a parabola.
Represents a 2D conic segment using two points.
Fits a conic to a set of points using linear regression.
T cross_product(v const &a, v const &b)
cross product of two vectors (area of enclosed parallellogram).
void add_point(vgl_point_2d< T > const &p)
add a point to the curve.
Fits a contiguous set of conic segments to a sampled curve.
direction vector in Euclidean 2D space
bool fit()
the fitting method.
void clear()
clear internal data.
Represents a homogeneous 2D point.