core/vgl/algo/vgl_h_matrix_2d_compute_linear.h
Go to the documentation of this file.
00001 #ifndef vgl_h_matrix_2d_compute_linear_h_
00002 #define vgl_h_matrix_2d_compute_linear_h_
00003 //:
00004 // \file
00005 // \brief contains class vgl_h_matrix_2d_compute_linear
00006 //
00007 // vgl_h_matrix_2d_compute_linear contains a linear method to calculate
00008 // the plane projectivity which relates four 2D point (or plane)
00009 // correspondences.
00010 // The returned $H$ is such that
00011 // $H  [p_1  p_2  p_3  p_4 ] \sim [p'_1  p'_2  p'_3  p'_4 ]$
00012 // where the $p_i$ are the homogeneous points in the first view, and the
00013 // $p'_i$ their images.
00014 //
00015 // \verbatim
00016 //  Modifications
00017 //   200598 FSM added checks for degenerate or coincident points.
00018 //   230603 Peter Vanroose - made compute_pl() etc. pure virtual
00019 //   240603 Peter Vanroose - added rough first implementation for compute_pl()
00020 // \endverbatim
00021 
00022 #include <vgl/algo/vgl_h_matrix_2d_compute.h>
00023 
00024 class vgl_h_matrix_2d_compute_linear : public vgl_h_matrix_2d_compute
00025 {
00026   bool allow_ideal_points_;
00027  protected:
00028   //: compute from matched points
00029   virtual
00030   bool compute_p(vcl_vector<vgl_homg_point_2d<double> > const& points1,
00031                  vcl_vector<vgl_homg_point_2d<double> > const& points2,
00032                  vgl_h_matrix_2d<double>& H);
00033 
00034   //:compute from matched lines
00035   virtual
00036   bool compute_l(vcl_vector<vgl_homg_line_2d<double> > const& lines1,
00037                  vcl_vector<vgl_homg_line_2d<double> > const& lines2,
00038                  vgl_h_matrix_2d<double>& H);
00039 
00040   //:compute from matched lines with weight vector
00041   virtual
00042   bool compute_l(vcl_vector<vgl_homg_line_2d<double> > const& lines1,
00043                  vcl_vector<vgl_homg_line_2d<double> > const& lines2,
00044                  vcl_vector<double> const& weights,
00045                  vgl_h_matrix_2d<double>& H);
00046 
00047   //:compute from matched points and lines
00048   virtual
00049   bool compute_pl(vcl_vector<vgl_homg_point_2d<double> > const& points1,
00050                   vcl_vector<vgl_homg_point_2d<double> > const& points2,
00051                   vcl_vector<vgl_homg_line_2d<double> > const& lines1,
00052                   vcl_vector<vgl_homg_line_2d<double> > const& lines2,
00053                   vgl_h_matrix_2d<double>& H);
00054 
00055   //:Assumes all corresponding points have equal weight
00056   bool solve_linear_problem(int equ_count,
00057                             vcl_vector<vgl_homg_point_2d<double> > const& p1,
00058                             vcl_vector<vgl_homg_point_2d<double> > const& p2,
00059                             vgl_h_matrix_2d<double>& H);
00060 
00061   //: for lines, the solution should be weighted by line length
00062   bool
00063   solve_weighted_least_squares(vcl_vector<vgl_homg_line_2d<double> > const& l1,
00064                                vcl_vector<vgl_homg_line_2d<double> > const& l2,
00065                                vcl_vector<double> const& w,
00066                                vgl_h_matrix_2d<double>& H);
00067 
00068  public:
00069   vgl_h_matrix_2d_compute_linear(bool allow_ideal_points = false);
00070   int minimum_number_of_correspondences() const { return 4; }
00071 };
00072 
00073 #endif // vgl_h_matrix_2d_compute_linear_h_