vpgl_calibration_matrix.h
Go to the documentation of this file.
1 // This is core/vpgl/vpgl_calibration_matrix.h
2 #ifndef vpgl_calibration_matrix_h_
3 #define vpgl_calibration_matrix_h_
4 //:
5 // \file
6 // \brief A class for the calibration matrix component of a perspective camera matrix.
7 // \author Thomas Pollard
8 // \date January 28, 2005
9 // \author Joseph Mundy, Matt Leotta, Vishal Jain
10 //
11 // \verbatim
12 // Modifications
13 // May 08, 2004 Ricardo Fabbri Added binary I/O support
14 // May 08, 2004 Ricardo Fabbri Added == operator
15 // \endverbatim
16 //
17 
18 #include <iostream>
19 #include <vgl/vgl_fwd.h>
20 #include <vnl/vnl_fwd.h>
21 #include <vnl/vnl_matrix_fixed.h>
22 #include <vgl/vgl_point_2d.h>
23 
24 // not used? #include <vcl_compiler.h>
25 
26 //: A class representing the "K" matrix of a perspective camera matrix as described in
27 // Hartley and Zisserman, "Multiple View Geometry".
28 template <class T>
30 {
31  public:
32  //: Default constructor makes an identity matrix.
34 
35  //: Destructor
36  virtual ~vpgl_calibration_matrix() = default;
37 
38  //: Construct using all of the camera parameters.
39  // Must satisfy the following requirements: x,y_scales must be > 0, focal_length must be not equal to 0.
41  T x_scale = (T)1, T y_scale = (T)1, T skew = (T)0 );
42 
43  //: Construct from a right upper triangular matrix whose decomposition into the calibration components makes sense.
44  // The supplied matrix can be a scalar multiple of such a matrix.
46 
47  //: Get the calibration matrix.
49 
50  //: Getters and setters for all of the parameters.
51  void set_focal_length( T new_focal_length );
52  void set_principal_point( const vgl_point_2d<T>& new_principal_point );
53  void set_x_scale( T new_x_scale );
54  void set_y_scale( T new_y_scale );
55  void set_skew( T new_skew );
56 
57  T focal_length() const { return focal_length_; }
59  T x_scale() const { return x_scale_; }
60  T y_scale() const { return y_scale_; }
61  T skew() const { return skew_; }
62 
63  //: Equality tests
64  bool operator==(vpgl_calibration_matrix<T> const &that) const;
65  bool operator!=(vpgl_calibration_matrix<T> const &that) const
66  {return !(*this==that);}
67 
68  //: Maps to and from the focal plane
70 
71  vgl_point_2d<T> map_to_image(vgl_point_2d<T> const& p_focal_plane) const;
72 
73  protected:
74  //: The following is a list of the parameters in the calibration matrix.
78 };
79 
80 
81 
82 #endif // vpgl_calibration_matrix_h_
vpgl_calibration_matrix()
Default constructor makes an identity matrix.
vgl_point_2d< T > principal_point() const
vgl_point_2d< T > map_to_image(vgl_point_2d< T > const &p_focal_plane) const
virtual ~vpgl_calibration_matrix()=default
Destructor.
A class representing the "K" matrix of a perspective camera matrix as described in.
void set_principal_point(const vgl_point_2d< T > &new_principal_point)
T focal_length_
The following is a list of the parameters in the calibration matrix.
vnl_matrix_fixed< T, 3, 3 > get_matrix() const
Get the calibration matrix.
vgl_point_2d< T > principal_point_
vgl_point_2d< T > map_to_focal_plane(vgl_point_2d< T > const &p_image) const
Maps to and from the focal plane.
void set_focal_length(T new_focal_length)
Getters and setters for all of the parameters.
bool operator!=(vpgl_calibration_matrix< T > const &that) const
bool operator==(vpgl_calibration_matrix< T > const &that) const
Equality tests.