19 #include <vnl/algo/vnl_levenberg_marquardt.h>
24 o <<
"********" << std::endl;
25 o <<
"a_shape:" << std::endl;
26 o <<
"********" << std::endl;
27 o <<
"This library provides classes to fit shapes to point clouds." << std::endl;
28 o <<
"classes: a_shape_line, a_shape_circle, a_shape_sphere, a_shape_plane, a_shape_quadric, a_shape_cylinder" << std::endl;
29 o <<
"use a_shape_line_help for more explanations." << std::endl;
62 return sqrt(d/pts.size());
84 const double P = log(1.-
P_);
87 vnl_vector<double> bpara;
89 std::vector<a_point> bfit;
103 std::cerr <<
"proportion of inliers: " << w*100 <<
"%" << std::endl;
106 double niterd =
P/log(1.-exp(
npara*log(w)));
109 niter = int(niterd+.5);
112 std::cerr << i <<
" " << niterd << std::endl;
118 std::cerr <<
"RANSAC: number of random tests: " << i << std::endl;
119 std::cerr << nf0 <<
" inliers in a cloud of " << pts.size()
120 <<
" points (RANSAC sample)" <<std::endl;
129 std::cerr <<
"rms dist (RANSAC sample, before LSF): " << this->
rms_dist_cloud(pts) << std::endl;
131 vnl_vector<double> x = x0;
132 vnl_levenberg_marquardt levmarq(f);
136 std::cerr <<
"Least Squares Fitting (Levenberg Marquardt)" << std::endl
137 <<
"min: " << levmarq.get_end_error() <<
" at " << x << std::endl;
138 levmarq.diagnose_outcome();
139 std::cerr <<
"rms dist (RANSAC sample, after LSF): " << this->
rms_dist_cloud(pts) << std::endl;
155 std::cout <<
n << std::endl;
160 std::cout <<
pt << std::endl;
177 std::cout <<
n << std::endl;
182 std::cout <<
pt << std::endl;
195 o <<
v.classname() << std::endl;
196 o <<
v.small() << std::endl;
197 o <<
v.getparameters() << std::endl;
std::ostream & operator<<(std::ostream &o, const a_shape &v)
double rms_dist_cloud(const std::vector< a_point > &pts)
vnl_vector< double > para_
double dist_cloud(const std::vector< a_point > &pts)
void export_outliers(const std::vector< a_point > &pts)
virtual void random_hint(const std::vector< a_point > &pts)=0
int threshold_cloud(const std::vector< a_point > &pts, std::vector< a_point > &pts2)
unsigned int npara() const
double average_dist_cloud(const std::vector< a_point > &pts)
void fit_cloud(const std::vector< a_point > &pts, vnl_least_squares_function &fn)
static const std::string help()
virtual double dist_point(const a_point p) const =0
vnl_vector< double > getparameters() const
int best_fitting_cloud(const std::vector< a_point > &pts, std::vector< a_point > &pts2)
void export_inliers(const std::vector< a_point > &pts)
double v(const uint32_t step, const uint32_t n)