2 #ifndef vpgl_fundamental_matrix_hxx_ 3 #define vpgl_fundamental_matrix_hxx_ 26 # include <vcl_msvc_warnings.h> 34 : cached_svd_(nullptr)
37 default_matrix(0,0) = default_matrix(1,1) = (T)1;
46 : cached_svd_(nullptr)
59 : cached_svd_(nullptr)
92 er.
set(
v[0],
v[1],
v[2] );
93 v = cached_svd_->left_nullvector();
94 el.
set(
v[0],
v[1],
v[2] );
127 get_epipoles(er, el);
132 get_matrix().transpose() *
147 get_epipoles(er, el);
166 get_epipoles( er, el );
168 elx.
put( 0, 1, -el.
w() ); elx.
put( 0, 2, el.
y() );
169 elx.
put( 1, 0, el.
w() ); elx.
put( 1, 2, -el.
x() );
170 elx.
put( 2, 0, -el.
y() ); elx.
put( 2, 1, el.
x() );
173 elvt(0,0) = el.
x()*
v[0]; elvt(1,0) = el.
y()*
v[0]; elvt(2,0) = el.
w()*
v[0];
174 elvt(0,1) = el.
x()*
v[1]; elvt(1,1) = el.
y()*
v[1]; elvt(2,1) = el.
w()*
v[1];
175 elvt(0,2) = el.
x()*
v[2]; elvt(1,2) = el.
y()*
v[2]; elvt(2,2) = el.
w()*
v[2];
191 assert( world_points.size() == image_points.size() );
192 assert( world_points.size() >= 2 );
195 get_epipoles( er, el );
197 elxF.
put( 0, 1, -el.w() ); elxF.
put( 0, 2, el.y() );
198 elxF.
put( 1, 0, el.w() ); elxF.
put( 1, 2, -el.x() );
199 elxF.
put( 2, 0, -el.y() ); elxF.
put( 2, 1, el.x() );
202 vnl_matrix<T> A(static_cast<unsigned int>(3 * image_points.size()), 4 );
204 for (
unsigned p = 0; p < image_points.size(); p++ ) {
206 world_points[p].x(), world_points[p].y(), world_points[p].z() );
208 image_points[p].x(), image_points[p].y(), (T)1 );
211 for (
unsigned i = 0; i < 3; i++ ) {
213 if ( i == 0 ) ei = el.x();
else if ( i == 1 ) ei = el.y();
else ei = el.w();
214 A(3*p+i,0) = ei*wp_vnl[0]; A(3*p+i,1) = ei*wp_vnl[1]; A(3*p+i,2) = ei*wp_vnl[2];
236 for (
unsigned i = 0; i<3; ++i)
237 nvtd[i] = static_cast<double>(nvt[i]);
240 for (
unsigned r = 0; r<3; ++r)
241 for (
unsigned c = 0; c<3; ++c)
242 e2xt[r][c] = static_cast<T>(e2x[r][c]);
253 if ( cached_svd_ !=
nullptr )
delete cached_svd_;
276 #undef vpgl_FUNDAMENTAL_MATRIX_INSTANTIATE 277 #define vpgl_FUNDAMENTAL_MATRIX_INSTANTIATE(T) \ 278 template class vpgl_fundamental_matrix<T >; \ 279 template std::ostream& operator<<(std::ostream&, const vpgl_fundamental_matrix<T >&); \ 280 template std::istream& operator>>(std::istream&, vpgl_fundamental_matrix<T >&) 282 #endif // vpgl_fundamental_matrix_hxx_ A class for the essential matrix between two projective cameras.
vnl_matrix_ref< T > as_ref()
A class for the fundamental matrix between two projective cameras.
vnl_svd< T > * svd() const
Get a copy of the svd of the get_matrix.
vgl_homg_line_2d< T > l_epipolar_line(const vgl_homg_point_2d< T > &pr) const
std::istream & operator>>(std::istream &is, vpgl_local_rational_camera< T > &p)
Read from stream.
void get_epipoles(vgl_homg_point_2d< T > &er, vgl_homg_point_2d< T > &el) const
Put the coordinates of the epipoles in er, el.
A class representing the "K" matrix of a perspective camera matrix as described in.
void put(unsigned r, unsigned c, T const &v)
const vpgl_fundamental_matrix< T > & operator=(const vpgl_fundamental_matrix< T > &fm)
Assignment.
static vnl_vector_fixed< T, 3 > get_vector(vgl_homg_point_2d< T > const &p)
vnl_matrix< T > solve(vnl_matrix< T > const &B) const
vnl_matrix_fixed< T, 1, 1 > vnl_inverse(vnl_matrix_fixed< T, 1, 1 > const &m)
bool extract_left_camera(const vpgl_essential_matrix< T > &E, const vgl_point_2d< T > &left_corr, const vgl_point_2d< T > &right_corr, vpgl_perspective_camera< T > &p_left, const T translation_mag=(T) 1)
Left camera extractor. Normalized correspondence pair is needed to determine which of four solutions ...
vnl_matrix_fixed< T, num_cols, num_rows > transpose() const
vnl_matrix_fixed< T, 3, 3 > F_
Internal representation of the fundamental matrix.
vnl_matrix_fixed< T, 3, 3 > get_matrix() const
Get the calibration matrix.
vpgl_fundamental_matrix()
Default constructor creates dummy rank 2 matrix.
std::ostream & operator<<(std::ostream &s, const vpgl_local_rational_camera< T > &p)
Write to stream.
void set(T px, T py, T pw=(T) 1)
const vnl_matrix_fixed< T, 3, 4 > & get_matrix() const
Return a copy of the camera matrix.
vpgl_proj_camera< T > extract_left_camera(const vnl_vector_fixed< T, 3 > &v, T lambda) const
Gives the left camera matrix corresponding to the fundamental matrix.
virtual ~vpgl_fundamental_matrix()
Destructor.
vnl_matrix_fixed & set_column(unsigned i, T const *v)
vgl_homg_line_2d< T > r_epipolar_line(const vgl_homg_point_2d< T > &pl) const
Given a point in one image, find the corresponding epipolar line in the other image.
const vnl_matrix_fixed< T, 3, 3 > & get_matrix() const
Get a copy of the FM in vnl form.
vnl_matrix_fixed & set_columns(unsigned starting_column, vnl_matrix< T > const &M)
A class for the calibration matrix component of a perspective camera matrix.
void set_matrix(const vpgl_proj_camera< T > &cr, const vpgl_proj_camera< T > &cl)