2 #ifndef vpgl_calibration_matrix_hxx_ 3 #define vpgl_calibration_matrix_hxx_ 16 # include <vcl_msvc_warnings.h> 22 focal_length_( (T)1 ),
34 T focal_length,
const vgl_point_2d<T>& principal_point, T x_scale, T y_scale, T skew ) :
35 focal_length_( focal_length ),
36 principal_point_( principal_point ),
54 assert( K(2,2) != (T)0 && K(1,0) == (T)0 && K(2,0) == (T)0 && K(2,1) == (T)0 );
55 double scale_factor = 1.0;
56 if ( K(2,2) != (T)1 ) scale_factor /= (double)K(2,2);
59 x_scale_ = T(scale_factor*K(0,0));
60 y_scale_ = T(scale_factor*K(1,1));
61 skew_ = T(scale_factor*K(0,1));
62 principal_point_.set( T(scale_factor*K(0,2)), T(scale_factor*K(1,2)) );
64 assert( ( x_scale_ > 0 && y_scale_ > 0 ) || ( x_scale_ < 0 && y_scale_ < 0 ) );
74 K(0,0) = focal_length_*x_scale_;
75 K(1,1) = focal_length_*y_scale_;
77 K(0,2) = principal_point_.x();
78 K(1,2) = principal_point_.y();
88 assert( new_focal_length != (T)0 );
89 focal_length_ = new_focal_length;
98 assert( !new_principal_point.
ideal() );
99 principal_point_ = new_principal_point;
107 assert( new_x_scale > 0 );
108 x_scale_ = new_x_scale;
116 assert( new_y_scale > 0 );
117 y_scale_ = new_y_scale;
139 this->skew_ == that.
skew_;
165 #undef vpgl_CALIBRATION_MATRIX_INSTANTIATE 166 #define vpgl_CALIBRATION_MATRIX_INSTANTIATE(T) \ 167 template class vpgl_calibration_matrix<T > 169 #endif // vpgl_calibration_matrix_hxx_
vpgl_calibration_matrix()
Default constructor makes an identity matrix.
vgl_point_2d< T > map_to_image(vgl_point_2d< T > const &p_focal_plane) const
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.
bool ideal(T=(T) 0) const
vnl_matrix_fixed< T, 1, 1 > vnl_inverse(vnl_matrix_fixed< T, 1, 1 > const &m)
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_skew(T new_skew)
void set_y_scale(T new_y_scale)
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
Equality tests.
A class for the calibration matrix component of a perspective camera matrix.
void set_x_scale(T new_x_scale)