2 #ifndef vgl_h_matrix_2d_optimize_h_ 3 #define vgl_h_matrix_2d_optimize_h_ 17 # include <vcl_msvc_warnings.h> 20 #include <vnl/vnl_least_squares_function.h> 37 : vnl_least_squares_function(9, 2*from_points.size() + 1, no_gradient)
39 n_ = from_points.size();
40 assert(
n_==to_points.size());
41 for (
unsigned i = 0; i<
n_; ++i)
54 void f(
const vnl_vector<double>& hv, vnl_vector<double>& proj_err)
override 57 assert(proj_err.size()==2*
n_+1);
61 for (
unsigned i = 0; i<
n_; ++i, k+=2)
66 double xproj = p_proj.
x(), yproj = p_proj.
y();
67 proj_err[k]=(xp-xproj); proj_err[k+1]=(yp-yproj);
69 proj_err[2*
n_]=1.0-hv.magnitude();
131 return optimize_pl(points1, points2, lines1, lines2, H);
177 #endif // vgl_h_matrix_2d_optimize_h_ void set_verbose(bool v)
set this to true for verbose run-time information.
virtual ~vgl_h_matrix_2d_optimize()=default
virtual bool optimize_p(std::vector< vgl_homg_point_2d< double > > const &points1, std::vector< vgl_homg_point_2d< double > > const &points2, vgl_h_matrix_2d< double > &H)=0
vgl_h_matrix_2d< double > initial_h_
Represents a homogeneous 2D line.
std::vector< vgl_homg_point_2d< double > > from_points_
virtual bool optimize_pl(std::vector< vgl_homg_point_2d< double > >const &points1, std::vector< vgl_homg_point_2d< double > >const &points2, std::vector< vgl_homg_line_2d< double > > const &lines1, std::vector< vgl_homg_line_2d< double > > const &lines2, vgl_h_matrix_2d< double > &H)=0
std::vector< vgl_point_2d< double > > to_points_
3x3 plane-to-plane projectivity
line in projective 2D space
virtual bool optimize_l(std::vector< vgl_homg_line_2d< double > > const &lines1, std::vector< vgl_homg_line_2d< double > > const &lines2, vgl_h_matrix_2d< double > &H)=0
void set_htol(const double htol)
Termination tolerance on change in the solution.
void set_gtol(const double gtol)
Termination tolerance on the gradient of the projection error.
bool optimize(std::vector< vgl_homg_point_2d< double > > const &points1, std::vector< vgl_homg_point_2d< double > > const &points2, std::vector< vgl_homg_line_2d< double > > const &lines1, std::vector< vgl_homg_line_2d< double > > const &lines2, vgl_h_matrix_2d< double > &H)
optimize homography from matched points and lines.
projection_lsqf(std::vector< vgl_homg_point_2d< double > > const &from_points, std::vector< vgl_homg_point_2d< double > > const &to_points)
vgl_h_matrix_2d_optimize(vgl_h_matrix_2d< double > const &initial_h)
bool optimize(std::vector< vgl_homg_line_2d< double > > const &lines1, std::vector< vgl_homg_line_2d< double > > const &lines2, vgl_h_matrix_2d< double > &H)
optimize homography from matched lines.
vgl_h_matrix_2d< double > optimize(std::vector< vgl_homg_point_2d< double > > const &p1, std::vector< vgl_homg_point_2d< double > > const &p2, std::vector< vgl_homg_line_2d< double > > const &l1, std::vector< vgl_homg_line_2d< double > > const &l2)
optimize homography from matched points and lines - return h_matrix.
~projection_lsqf() override=default
point in projective 2D space
void f(const vnl_vector< double > &hv, vnl_vector< double > &proj_err) override
compute the projection error given a set of h parameters.
vgl_h_matrix_2d< double > optimize(std::vector< vgl_homg_point_2d< double > > const &p1, std::vector< vgl_homg_point_2d< double > > const &p2)
optimize homography from matched points - return h_matrix.
void set_trace(bool trace)
Termination tolerance on the gradient of the projection error.
Represents a cartesian 2D point.
vgl_h_matrix_2d< double > optimize(std::vector< vgl_homg_line_2d< double > > const &l1, std::vector< vgl_homg_line_2d< double > > const &l2)
optimize homography from matched lines - return h_matrix.
Represents a homogeneous 2D point.
bool optimize(std::vector< vgl_homg_point_2d< double > > const &points1, std::vector< vgl_homg_point_2d< double > > const &points2, vgl_h_matrix_2d< double > &H)
optimize homography from matched points.
virtual int minimum_number_of_correspondences() const =0
void set_ftol(const double ftol)
Termination tolerance on the sum of squared projection errors.