1 #ifndef vgl_h_matrix_2d_optimize_lmq_h_ 2 #define vgl_h_matrix_2d_optimize_lmq_h_ 3 //: 4 // \file 5 // \author J.L. Mundy Jan 05, 2005 6 // \brief contains class vgl_h_matrix_2d_optimize_lmq 7 // 8 // vgl_h_matrix_2d_optimize_lmq uses the Levenberg-Marquardt algorithm 9 // to refine an initial value for vgl_h_matrix_2d, given a set of corresponding 10 // points or lines. The number of points/lines must be greater than four, 11 // since for four or fewer points/lines the projective mapping is exact. 12 // \verbatim 13 // Modifications 14 // none 15 // \endverbatim 16 17 #include <vgl/algo/vgl_h_matrix_2d_optimize.h> 18 19 class vgl_h_matrix_2d_optimize_lmq : public vgl_h_matrix_2d_optimize 20 { 21 public: 22 //: Constructor from initial homography to be optimized 23 vgl_h_matrix_2d_optimize_lmq(vgl_h_matrix_2d<double> const& initial_h); 24 minimum_number_of_correspondences()25 int minimum_number_of_correspondences() const override { return 5; } 26 27 protected: // -- internal utilities -- 28 29 //:the main routine for carrying out the optimization. (used by the others) 30 bool optimize_h(std::vector<vgl_homg_point_2d<double> > const& points1, 31 std::vector<vgl_homg_point_2d<double> > const& points2, 32 vgl_h_matrix_2d<double> const& h_initial, 33 vgl_h_matrix_2d<double>& h_optimized); 34 35 //: compute from matched points 36 37 bool optimize_p(std::vector<vgl_homg_point_2d<double> > const& points1, 38 std::vector<vgl_homg_point_2d<double> > const& points2, 39 vgl_h_matrix_2d<double>& H) override; 40 41 //:compute from matched lines 42 43 bool optimize_l(std::vector<vgl_homg_line_2d<double> > const& lines1, 44 std::vector<vgl_homg_line_2d<double> > const& lines2, 45 vgl_h_matrix_2d<double>& H) override; 46 47 //:compute from matched points and lines 48 49 bool optimize_pl(std::vector<vgl_homg_point_2d<double> > const& points1, 50 std::vector<vgl_homg_point_2d<double> > const& points2, 51 std::vector<vgl_homg_line_2d<double> > const& lines1, 52 std::vector<vgl_homg_line_2d<double> > const& lines2, 53 vgl_h_matrix_2d<double>& H) override; 54 }; 55 56 #endif // vgl_h_matrix_2d_optimize_lmq_h_ 57