vgl_h_matrix_1d_compute.h
Go to the documentation of this file.
1 #ifndef vgl_h_matrix_1d_compute_h_
2 #define vgl_h_matrix_1d_compute_h_
3 //:
4 // \file
5 // \brief Virtual base class of classes to generate a line-to-line projectivity from a set of matched points
6 //
7 // \author
8 // Frederik Schaffalitzky , Robotic Research Group
9 //
10 // \verbatim
11 // Modifications
12 // 23 Mar 2003 - J.L. Mundy - preparing for upgrade to vgl
13 // computations restricted to vgl_homg_point_1d<double>
14 // Seems somewhat overdoing it to template the transform
15 // solvers since double is needed for robust computation
16 // 23 Jun 2003 - Peter Vanroose - made compute_cool_homg pure virtual
17 // 24 Jun 2003 - Peter Vanroose - implemented the second compute() method
18 // 13 Jun 2004 - Peter Vanroose - added compute() overload, similar to 2d interface
19 // \endverbatim
20 
21 #include <vector>
22 #include <vgl/vgl_homg_point_1d.h>
24 #ifdef _MSC_VER
25 # include <vcl_msvc_warnings.h>
26 #endif
27 
29 {
30  public:
31  //
33  virtual ~vgl_h_matrix_1d_compute() = default;
34 
35  //: set this to true for verbose run-time information; default is false
36  void verbose(bool v) { verbose_=v; }
37 
38  //
39  // Compute methods :
40  //
41 
42  //: principal interface: given point correspondences in p1,p2, returns H
43  bool compute(const std::vector<vgl_homg_point_1d<double> >& p1,
44  const std::vector<vgl_homg_point_1d<double> >& p2,
46  { return compute_cool_homg(p1,p2,H); } // calls pure virtual function
47 
48  //: nonhomogeneous interface: given point correspondences in p1,p2, returns H
49  bool compute(const double p1[],
50  const double p2[],
51  unsigned int length, // length of both p1 and p2
53  { return compute_array_dbl(p1,p2,length,H); }
54 
55  //: homography from matched points - return h_matrix
57  compute(std::vector<vgl_homg_point_1d<double> > const& p1,
58  std::vector<vgl_homg_point_1d<double> > const& p2)
59  { vgl_h_matrix_1d<double> H; compute(p1, p2, H); return H; }
60 
61  protected:
62  bool verbose_;
63 
64  virtual bool compute_cool_homg(const std::vector<vgl_homg_point_1d<double> > &,
65  const std::vector<vgl_homg_point_1d<double> > &,
67 
68  bool compute_array_dbl(const double p1[], const double p2[], unsigned int length,
70  {
71  std::vector<vgl_homg_point_1d<double> > pt1; pt1.reserve(length);
72  std::vector<vgl_homg_point_1d<double> > pt2; pt2.reserve(length);
73  for (unsigned int i=0;i<length; ++i) {
74  pt1.emplace_back(p1[i],1.0);
75  pt2.emplace_back(p2[i],1.0);
76  }
77  return compute_cool_homg(pt1,pt2,H); // pure virtual function
78  }
79 };
80 
81 #endif // vgl_h_matrix_1d_compute_h_
bool compute(const double p1[], const double p2[], unsigned int length, vgl_h_matrix_1d< double > &H)
nonhomogeneous interface: given point correspondences in p1,p2, returns H.
virtual ~vgl_h_matrix_1d_compute()=default
2x2 line-to-line projectivity
A class to hold a line-to-line projective transformation matrix and to perform common operations usin...
Definition: vgl_algo_fwd.h:10
void verbose(bool v)
set this to true for verbose run-time information; default is false.
a point in homogeneous 1-D space, i.e., a homogeneous pair (x,w)
vgl_h_matrix_1d< double > compute(std::vector< vgl_homg_point_1d< double > > const &p1, std::vector< vgl_homg_point_1d< double > > const &p2)
homography from matched points - return h_matrix.
#define v
Definition: vgl_vector_2d.h:74
bool compute(const std::vector< vgl_homg_point_1d< double > > &p1, const std::vector< vgl_homg_point_1d< double > > &p2, vgl_h_matrix_1d< double > &H)
principal interface: given point correspondences in p1,p2, returns H.
bool compute_array_dbl(const double p1[], const double p2[], unsigned int length, vgl_h_matrix_1d< double > &H)
virtual bool compute_cool_homg(const std::vector< vgl_homg_point_1d< double > > &, const std::vector< vgl_homg_point_1d< double > > &, vgl_h_matrix_1d< double > &H)=0
Represents a homogeneous 1-D point, i.e., a homogeneous pair (x,w).
Definition: vgl_fwd.h:7
double length(v const &a)
Return the length of a vector.
Definition: vgl_vector_2d.h:94