2 #ifndef vgl_p_matrix_h_ 3 #define vgl_p_matrix_h_ 29 # include <vcl_msvc_warnings.h> 32 #include <vnl/algo/vnl_algo_fwd.h> 33 #include <vnl/vnl_matrix.h> 34 #include <vnl/vnl_vector.h> 35 #include <vnl/vnl_matrix_fixed.h> 36 #include <vnl/vnl_vector_fixed.h> 63 explicit vgl_p_matrix(vnl_matrix_fixed<T, 3, 4>
const& P);
65 vgl_p_matrix(
const vnl_matrix_fixed<T,3,3>& A,
const vnl_vector_fixed<T,3>& a)
117 vnl_svd<T>*
svd()
const;
151 void get(vnl_matrix_fixed<T,3,3>* A, vnl_vector_fixed<T,3>* a)
const;
153 void get(vnl_matrix<T>* A, vnl_vector<T>* a)
const;
156 void get_rows(vnl_vector<T>* a, vnl_vector<T>* b, vnl_vector<T>* c)
const;
158 void get_rows(vnl_vector_fixed<T,4>* a, vnl_vector_fixed<T,4>* b, vnl_vector_fixed<T,4>* c)
const;
160 vgl_p_matrix&
set_rows(
const vnl_vector_fixed<T,4>& a,
const vnl_vector_fixed<T,4>& b,
const vnl_vector_fixed<T,4>& c);
163 T
get(
unsigned int row_index,
unsigned int col_index)
const;
165 void get(T *c_matrix)
const;
167 void get(vnl_matrix_fixed<T, 3, 4>& p_matrix)
const { p_matrix =
p_matrix_; }
169 void get(vnl_matrix<T>& p_matrix)
const { p_matrix =
p_matrix_.as_ref(); }
176 vgl_p_matrix&
set(vnl_matrix_fixed<T,3,3>
const& A, vnl_vector_fixed<T,3>
const& a);
212 #define VGL_P_MATRIX_INSTANTIATE(T) extern "please include vgl/algo/vgl_p_matrix.hxx first" 214 #endif // vgl_p_matrix_h_
point in projective 3D space
const vnl_matrix_fixed< T, 3, 4 > & get_matrix() const
vgl_homg_point_2d< T > operator *(vgl_homg_point_3d< T > const &X) const
Return the image point which is the projection of the specified 3D point X.
vgl_p_matrix & flip_sign()
Change the overall sign of the P matrix.
Represents a homogeneous 2D line.
bool is_behind_camera(vgl_homg_point_3d< T > const &)
Return true if the 3D point X is behind the camera represented by this P.
void get(vnl_matrix_fixed< T, 3, 4 > &p_matrix) const
Return the 3x4 projection matrix in p_matrix.
void get(vnl_matrix_fixed< T, 3, 3 > *A, vnl_vector_fixed< T, 3 > *a) const
Return the 3x3 matrix and 3x1 column vector of P = [A a].
bool read_ascii(std::istream &f)
Load from file.
vgl_homg_point_3d< T > get_focal() const
Return the 3D point representing the focal point of the camera.
std::ostream & operator<<(std::ostream &s, vgl_orient_box_3d< Type > const &p)
Write box to stream.
vgl_h_matrix_3d< T > get_canonical_H() const
Return the 3D H-matrix s.t. P * H = [I 0].
line in projective 2D space
bool is_canonical(T tol=0) const
Return true iff P is [I 0].
Represents a homogeneous 3D point.
void get(vnl_matrix< T > &p_matrix) const
Deprecated; use the vnl_matrix_fixed variant instead.
void clear_svd() const
Discredit the cached svd.
static vgl_p_matrix read(const char *filename)
Load from file.
line segment in 3D nonhomogeneous space
vgl_p_matrix & set(const vnl_matrix< T > &p_matrix)
Deprecated; use the vnl_matrix_fixed variant instead.
vnl_matrix_fixed< T, 3, 4 > p_matrix_
A class to hold a 3-d projective transformation matrix and to perform common operations using it e....
vgl_p_matrix & operator=(const vgl_p_matrix &)
Represents a 3D line segment using two points.
vgl_p_matrix()
Constructor. Set up a canonical P matrix.
vgl_p_matrix(const vnl_matrix_fixed< T, 3, 3 > &A, const vnl_vector_fixed< T, 3 > &a)
Construct from 3x3 matrix A and vector a. P = [A a].
vgl_p_matrix & set_identity()
Set the camera to an identity projection. X->u, Y->v.
vgl_p_matrix & set(vnl_matrix_fixed< T, 3, 4 > const &p_matrix)
Set the internal matrix using the 3x4 p_matrix.
vgl_homg_line_3d_2_points< T > backproject(vgl_homg_point_2d< T > const &x) const
Return the 3D line which is the backprojection of the specified image point, x.
point in projective 2D space
vgl_p_matrix & set_rows(const vnl_vector_fixed< T, 4 > &a, const vnl_vector_fixed< T, 4 > &b, const vnl_vector_fixed< T, 4 > &c)
Set P = [a b c]' from its rows a, b, c.
std::istream & operator>>(std::istream &is, vgl_orient_box_3d< Type > &p)
Read box from stream.
vgl_homg_point_3d< T > backproject_pseudoinverse(vgl_homg_point_2d< T > const &x) const
Return the 3D point $\vec X$ which is $\vec X = P^+ \vec x$.
bool operator==(vgl_p_matrix const &p) const
vgl_homg_point_1d< T > operator *(vnl_matrix_fixed< T, 2, 2 > const &m, vgl_homg_point_1d< T > const &p)
Transform a point through a 2x2 projective transformation matrix.
Represents a homogeneous 2D point.
4x4 3D-to-3D projectivity
vgl_p_matrix< T > postmultiply(vnl_matrix_fixed< T, 4, 4 > const &H) const
post-multiply this projection matrix with a 3-d projective transform.
vgl_p_matrix(const vnl_matrix< T > &A, const vnl_vector< T > &a)
Deprecated; use the vnl_matrix_fixed variant instead.
bool looks_conditioned()
Splendid hack that tries to detect if the P is an image-coords P or a normalized P.
void get_rows(vnl_vector< T > *a, vnl_vector< T > *b, vnl_vector< T > *c) const
Return the rows of P = [a b c]'.
vgl_p_matrix & fix_cheirality()
Scale P so determinant of first 3x3 is 1.
vgl_homg_point_2d< T > operator()(vgl_homg_point_3d< T > const &X) const
Return the image point which is the projection of the specified 3D point X.
vgl_p_matrix< T > premultiply(vnl_matrix_fixed< T, 3, 3 > const &H) const
pre-multiply this projection matrix with a 2-d projective transform.
Represents a homogeneous 3D line using two points.
vnl_svd< T > * svd() const
Compute the svd of this P and cache it, so that future operations that require it need not recompute ...