Go to the documentation of this file.00001
00002 #ifndef vpgl_generic_camera_h_
00003 #define vpgl_generic_camera_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <vbl/vbl_array_2d.h>
00026 #include <vgl/vgl_ray_3d.h>
00027 #include <vgl/vgl_point_3d.h>
00028 #include <vpgl/vpgl_camera.h>
00029 #include <vcl_iosfwd.h>
00030 #include <vcl_string.h>
00031
00032 template <class T>
00033 class vpgl_generic_camera : public vpgl_camera<T>
00034 {
00035 public:
00036
00037 vpgl_generic_camera();
00038 vpgl_generic_camera( vbl_array_2d<vgl_ray_3d<T> > const& rays);
00039
00040 virtual ~vpgl_generic_camera() {}
00041
00042 virtual vcl_string type_name() const { return "vpgl_generic_camera"; }
00043
00044
00045 virtual void project(const T x, const T y, const T z, T& u, T& v) const;
00046
00047
00048 unsigned cols(int level) const {return rays_[level].cols();}
00049 unsigned cols() const { return rays_[0].cols();}
00050
00051
00052 unsigned rows(int level) const {return rays_[level].rows();}
00053 unsigned rows() const { return rays_[0].rows();}
00054
00055
00056 unsigned n_levels() {return static_cast<unsigned>(n_levels_);}
00057
00058
00059 vgl_ray_3d<T> ray(const T u, const T v) const;
00060
00061
00062 vgl_ray_3d<T> ray(vgl_point_3d<T> const& p) const;
00063
00064
00065 vbl_array_2d<vgl_ray_3d<T> >& rays(int level) { return rays_[level];}
00066
00067
00068 vgl_point_3d<T> min_ray_origin() {return min_ray_origin_;}
00069 vgl_vector_3d<T> min_ray_direction() {return min_ray_direction_;}
00070
00071
00072 vgl_point_3d<T> max_ray_origin() {return max_ray_origin_;}
00073 vgl_vector_3d<T> max_ray_direction() {return max_ray_direction_;}
00074
00075
00076 void print_orig(int level);
00077
00078
00079 void print_to_vrml(int level, vcl_ostream& os);
00080
00081 protected:
00082 void nearest_ray_to_point(vgl_point_3d<T> const& p,
00083 int& nearest_r, int& nearest_c) const;
00084
00085 void nearest_ray(int level, vgl_point_3d<T> const& p,
00086 int start_r, int end_r, int start_c, int end_c,
00087 int& nearest_r, int& nearest_c) const;
00088
00089
00090 void refine_projection(int nearest_c, int nearest_r,
00091 vgl_point_3d<T> const& p, T& u, T& v) const;
00092
00093
00094 void refine_ray_at_point(int nearest_c, int nearest_r,
00095 vgl_point_3d<T> const& p,
00096 vgl_ray_3d<T>& ray) const;
00097
00098
00099
00100
00101 vgl_point_3d<T> min_ray_origin_;
00102 vgl_vector_3d<T> min_ray_direction_;
00103
00104 vgl_point_3d<T> max_ray_origin_;
00105 vgl_vector_3d<T> max_ray_direction_;
00106
00107
00108
00109 int n_levels_;
00110
00111 vcl_vector<int> nr_;
00112
00113 vcl_vector<int> nc_;
00114
00115 vcl_vector<vbl_array_2d<vgl_ray_3d<T> > > rays_;
00116 };
00117
00118 #endif // vpgl_generic_camera_h_