2 #ifndef vpgl_affine_camera_hxx_ 3 #define vpgl_affine_camera_hxx_ 16 # include <vcl_msvc_warnings.h> 26 view_distance_ = (T)0;
35 set_rows( row1, row2 );
36 view_distance_ = (T)0;
44 assert( camera_matrix(2,3) != 0 );
47 C(2,0) = (T)0; C(2,1) = (T)0; C(2,2) = (T)0;
49 view_distance_ = (T)0;
51 ray_dir_.set(cc.
x(), cc.
y(), cc.
z());
59 T u0, T v0, T su, T sv) {
63 if (std::fabs(dot_product<T>(uvec,rvec)-T(1))<1e-5)
71 else if (std::fabs(dot_product<T>(uvec,rvec)-T(-1))<1e-5)
86 T r[] = { x.
x(), x.
y(), x.
z(),
88 rvec.x(), rvec.y(), rvec.z() };
95 for (
unsigned i = 0; i<3; ++i) {
99 r0[3]= 0.0; r1[3]= 0.0;
100 this->set_rows(r0, r1);
102 this->project(stare_pt.
x(), stare_pt.
y(), stare_pt.
z(), u,
v);
106 this->set_rows(r0, r1);
107 view_distance_ = (T)0;
108 ray_dir_.set(rvec.x(), rvec.y(), rvec.z());
119 for (
unsigned int i = 0; i < 4; ++i ) {
128 ray_dir_.set(cc.
x(), cc.
y(), cc.
z());
135 assert( new_camera_matrix(2,3) != 0 );
138 C(2,0) = (T)0; C(2,1) = (T)0; C(2,2) = (T)0;
143 ray_dir_.
set(cc.
x(), cc.
y(), cc.
z());
147 orient_ray_direction(old_ray_dir);
155 set_matrix( new_camera_matrix );
185 std::cout <<
"Warning vpgl_affine_camera::backproject produced line at infinity\n";
212 ray_dir_.z(), view_distance_);
221 ray_dir_ = -ray_dir_;
226 template <
class Type>
235 template <
class Type>
247 #undef vpgl_AFFINE_CAMERA_INSTANTIATE 248 #define vpgl_AFFINE_CAMERA_INSTANTIATE(T) \ 249 template class vpgl_affine_camera<T >; \ 250 template std::ostream& operator<<(std::ostream&, const vpgl_affine_camera<T >&); \ 251 template std::istream& operator>>(std::istream&, vpgl_affine_camera<T >&) 254 #endif // vpgl_affine_camera_hxx_ A class for the affine camera model.
std::istream & operator >>(std::istream &s, vpgl_affine_camera< Type > &c)
Read camera from stream.
vgl_ray_3d< T > backproject_ray(const vgl_homg_point_2d< T > &image_point) const override
Find the 3d ray that goes through the camera center and the provided image point.
vpgl_affine_camera< T > * clone(void) const override
Clone ‘this’: creation of a new object and initialization.
vpgl_affine_camera()
Default constructor creates the canonical affine camera.
virtual bool set_matrix(const vnl_matrix_fixed< T, 3, 4 > &new_camera_matrix)
Setters mirror the constructors and return true if the setting was successful.
virtual vgl_homg_line_3d_2_points< T > backproject(const vgl_homg_point_2d< T > &image_point) const
Find the 3d ray that goes through the camera center and the provided image point.
virtual vgl_homg_point_3d< T > camera_center() const
Find the 3d coordinates of the center of the camera.
std::ostream & operator<<(std::ostream &s, const vpgl_local_rational_camera< T > &p)
Write to stream.
vgl_homg_line_3d_2_points< T > backproject(const vgl_homg_point_2d< T > &image_point) const override
Find the 3d ray that goes through the camera center.
vgl_homg_point_3d< T > camera_center() const override
Find the 3d coordinates of the center of the camera. Will be an ideal point with the sense of the ray...
void orient_ray_direction(vgl_vector_3d< T > const &look_dir)
flip the ray direction so that dot product with look_dir is positive.
const vnl_matrix_fixed< T, 3, 4 > & get_matrix() const
Return a copy of the camera matrix.
void set(T vx, T vy, T vz)
void set_rows(const vnl_vector_fixed< T, 4 > &row1, const vnl_vector_fixed< T, 4 > &row2)
Set the top two rows.
T dot_product(v const &a, v const &b)
bool is_ideal(l const &line, T tol=(T) 0)
vgl_homg_plane_3d< T > principal_plane() const override
Find the world plane perpendicular to the camera rays at viewing distance from the origin.
bool set_matrix(const vnl_matrix_fixed< T, 3, 4 > &new_camera_matrix) override
Setters mirror the constructors and return true if the setting was successful.
T cross_product(v const &a, v const &b)
vgl_homg_point_3d< Type > point_finite() const
vgl_point_2d< T > vgl_closest_point_origin(vgl_line_2d< T > const &l)