vgl_h_matrix_2d_compute.h
Go to the documentation of this file.
1 // This is core/vgl/algo/vgl_h_matrix_2d_compute.h
2 #ifndef vgl_h_matrix_2d_compute_h_
3 #define vgl_h_matrix_2d_compute_h_
4 //:
5 // \file
6 // \brief contains class vgl_h_matrix_2d_compute
7 //
8 // Abstract interface for classes that compute plane-to-plane
9 // projectivities from point and line correspondences.
10 //
11 // \verbatim
12 // Modifications
13 // 08-02-98 FSM
14 // 1. Added virtual compute methods that actually take arguments :
15 // generic estimator using points, lines or both.
16 // 2. Obsoleted bool compute(vgl_h_matrix_2d<double> *). So don't use it!
17 // 3. made arguments to compute method 'const ... &',
18 // thereby potentially breaking the code of certain other people.
19 //
20 // Mar 24, 2003 JLM Modifications to move to vgl algo
21 // May 15, 2003 JLM Added a weighted least squares interface for computing
22 // a homography from line correspondences.
23 // Jun 23, 2003 Peter Vanroose - made compute_pl() etc. pure virtual
24 // \endverbatim
25 #include <vector>
26 #ifdef _MSC_VER
27 # include <vcl_msvc_warnings.h>
28 #endif
29 #include <vgl/vgl_homg_point_2d.h>
30 #include <vgl/vgl_homg_line_2d.h>
32 
34 {
35  public:
37  virtual ~vgl_h_matrix_2d_compute() = default;
38 
39  // set this to true for verbose run-time information
40  void verbose(bool v) { verbose_ = v; }
41 
42  // fsm
43  virtual int minimum_number_of_correspondences() const = 0;
44 
45  // Compute methods :
46  //
47  // Some use point correspondences, some use line
48  // correspondences, some use both. They are implemented
49  // in terms of the pure virtual compute_(p|l|pl) methods.
50 
51  //: homography from matched points
52  bool compute(std::vector<vgl_homg_point_2d<double> > const& points1,
53  std::vector<vgl_homg_point_2d<double> > const& points2,
55  {
56  return compute_p(points1, points2, H);
57  }
58 
59  //: homography from matched lines
60  bool compute(std::vector<vgl_homg_line_2d<double> > const& lines1,
61  std::vector<vgl_homg_line_2d<double> > const& lines2,
63  {
64  return compute_l(lines1, lines2, H);
65  }
66 
67  //: homography from matched lines with a weight vector
68  bool compute(std::vector<vgl_homg_line_2d<double> > const& lines1,
69  std::vector<vgl_homg_line_2d<double> > const& lines2,
70  std::vector<double> const& weights,
72  {
73  return compute_l(lines1, lines2, weights, H);
74  }
75 
76  //: homography from matched points and lines
77  bool compute(std::vector<vgl_homg_point_2d<double> > const& points1,
78  std::vector<vgl_homg_point_2d<double> > const& points2,
79  std::vector<vgl_homg_line_2d<double> > const& lines1,
80  std::vector<vgl_homg_line_2d<double> > const& lines2,
82  {
83  return compute_pl(points1, points2, lines1, lines2, H);
84  }
85 
86  //: homography from matched points - return h_matrix
88  compute(std::vector<vgl_homg_point_2d<double> > const& p1,
89  std::vector<vgl_homg_point_2d<double> > const& p2)
90  { vgl_h_matrix_2d<double> H; compute_p(p1, p2, H); return H; }
91 
92  //: homography from matched lines - return h_matrix
94  compute(std::vector<vgl_homg_line_2d<double> > const& l1,
95  std::vector<vgl_homg_line_2d<double> > const& l2)
96  { vgl_h_matrix_2d<double> H; compute_l(l1, l2, H); return H; }
97 
98  //: homography from matched lines with weight vector - return h_matrix
100  compute(std::vector<vgl_homg_line_2d<double> > const& l1,
101  std::vector<vgl_homg_line_2d<double> > const& l2,
102  std::vector<double> const& weights)
103  { vgl_h_matrix_2d<double> H; compute_l(l1, l2, weights, H); return H; }
104 
105  //: homography from matched points and lines - return h_matrix
107  compute(std::vector<vgl_homg_point_2d<double> > const& p1,
108  std::vector<vgl_homg_point_2d<double> > const& p2,
109  std::vector<vgl_homg_line_2d<double> > const& l1,
110  std::vector<vgl_homg_line_2d<double> > const& l2)
111  { vgl_h_matrix_2d<double> H; compute_pl(p1, p2, l1, l2, H); return H; }
112 
113  protected:
114  bool verbose_;
115  virtual bool compute_p(std::vector<vgl_homg_point_2d<double> > const& points1,
116  std::vector<vgl_homg_point_2d<double> > const& points2,
117  vgl_h_matrix_2d<double>& H) = 0;
118 
119  virtual bool compute_l(std::vector<vgl_homg_line_2d<double> > const& lines1,
120  std::vector<vgl_homg_line_2d<double> > const& lines2,
121  vgl_h_matrix_2d<double>& H) = 0;
122 
123  virtual bool compute_l(std::vector<vgl_homg_line_2d<double> > const& lines1,
124  std::vector<vgl_homg_line_2d<double> > const& lines2,
125  std::vector<double> const& weights,
126  vgl_h_matrix_2d<double>& H) = 0;
127 
128  virtual bool compute_pl(std::vector<vgl_homg_point_2d<double> > const& points1,
129  std::vector<vgl_homg_point_2d<double> > const& points2,
130  std::vector<vgl_homg_line_2d<double> > const& lines1,
131  std::vector<vgl_homg_line_2d<double> > const& lines2,
132  vgl_h_matrix_2d<double>& H) = 0;
133 };
134 
135 #endif // vgl_h_matrix_2d_compute_h_
bool compute(std::vector< vgl_homg_line_2d< double > > const &lines1, std::vector< vgl_homg_line_2d< double > > const &lines2, vgl_h_matrix_2d< double > &H)
homography from matched lines.
bool compute(std::vector< vgl_homg_line_2d< double > > const &lines1, std::vector< vgl_homg_line_2d< double > > const &lines2, std::vector< double > const &weights, vgl_h_matrix_2d< double > &H)
homography from matched lines with a weight vector.
virtual ~vgl_h_matrix_2d_compute()=default
Represents a homogeneous 2D line.
Definition: vgl_fwd.h:14
virtual bool compute_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
virtual bool compute_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
virtual bool compute_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
3x3 plane-to-plane projectivity
line in projective 2D space
bool compute(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)
homography from matched points and lines.
vgl_h_matrix_2d< double > compute(std::vector< vgl_homg_point_2d< double > > const &p1, std::vector< vgl_homg_point_2d< double > > const &p2)
homography from matched points - return h_matrix.
#define v
Definition: vgl_vector_2d.h:74
bool compute(std::vector< vgl_homg_point_2d< double > > const &points1, std::vector< vgl_homg_point_2d< double > > const &points2, vgl_h_matrix_2d< double > &H)
homography from matched points.
vgl_h_matrix_2d< double > compute(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)
homography from matched points and lines - return h_matrix.
point in projective 2D space
vgl_h_matrix_2d< double > compute(std::vector< vgl_homg_line_2d< double > > const &l1, std::vector< vgl_homg_line_2d< double > > const &l2)
homography from matched lines - return h_matrix.
virtual int minimum_number_of_correspondences() const =0
vgl_h_matrix_2d< double > compute(std::vector< vgl_homg_line_2d< double > > const &l1, std::vector< vgl_homg_line_2d< double > > const &l2, std::vector< double > const &weights)
homography from matched lines with weight vector - return h_matrix.
Represents a homogeneous 2D point.
Definition: vgl_fwd.h:8