vgl_h_matrix_2d_compute_4point.cxx
Go to the documentation of this file.
1 // This is core/vgl/algo/vgl_h_matrix_2d_compute_4point.cxx
3 //:
4 // \file
5 #include <vnl/vnl_inverse.h>
6 #include <cassert>
7 #ifdef _MSC_VER
8 # include <vcl_msvc_warnings.h>
9 #endif
10 
11 //-----------------------------------------------------------------------------
12 //
13 //: Compute a plane-plane projectivity using 4 point correspondences.
14 // Returns false if the calculation fails or there are fewer than four point
15 // matches in the list.
16 //
17 // The algorithm determines the transformation $H_i$ from each pointset to the
18 // canonical projective basis (see h_matrix_2d::projective_basis), and
19 // returns the combined transform $H = H_2^{-1} H_1$.
21  std::vector<vgl_homg_point_2d<double> > const& points2,
23 {
25  if (!H1.projective_basis(points1))
26  return false;
27  if (!H2.projective_basis(points2))
28  return false;
29  H.set(vnl_inverse(H2.get_matrix()) * H1.get_matrix());
30  return true;
31 }
32 
33 //-----------------------------------------------------------------------------
34 //
35 //: Compute a plane-plane projectivity using 4 line correspondences.
36 // Returns false if the calculation fails or there are fewer than four line
37 // matches in the list.
38 //
39 // Implementation is the dual of the implementation of compute_p()
41  std::vector<vgl_homg_line_2d<double> > const& lines2,
43 {
45  if (!H1.projective_basis(lines1))
46  return false;
47  if (!H2.projective_basis(lines2))
48  return false;
49  H.set(vnl_inverse(H2.get_matrix()) * H1.get_matrix());
50  return true;
51 }
52 
54  std::vector<vgl_homg_line_2d<double> > const& lines2,
55  std::vector<double> const&,
57 {
59  if (!H1.projective_basis(lines1))
60  return false;
61  if (!H2.projective_basis(lines2))
62  return false;
63  H.set(vnl_inverse(H2.get_matrix()) * H1.get_matrix());
64  return true;
65 }
66 
68  std::vector<vgl_homg_point_2d<double> > const& /*points2*/,
69  std::vector<vgl_homg_line_2d<double> > const& /*lines1*/,
70  std::vector<vgl_homg_line_2d<double> > const& /*lines2*/,
72 {
73  assert(!"vgl_h_matrix_2d_compute_4point::compute_pl() NYI");
74  return false;
75 }
vnl_matrix_fixed< T, 3, 3 > const & get_matrix() const
Return the 3x3 homography matrix.
Represents a homogeneous 2D line.
Definition: vgl_fwd.h:14
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) override
compute from matched points and lines.
vgl_h_matrix_2d & set(unsigned int row_index, unsigned int col_index, T value)
Set an element of the 3x3 homography matrix.
vgl_h_matrix_2d_compute_linear contains a linear method to calculate the plane projectivity which rel...
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) override
compute from matched lines.
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) override
compute from matched points.
Represents a homogeneous 2D point.
Definition: vgl_fwd.h:8
bool projective_basis(std::vector< vgl_homg_point_2d< T > > const &four_points)
transformation to projective basis (canonical frame).