core/vpgl/vpgl_local_rational_camera.h
Go to the documentation of this file.
00001 // This is core/vpgl/vpgl_local_rational_camera.h
00002 #ifndef vpgl_local_rational_camera_h_
00003 #define vpgl_local_rational_camera_h_
00004 //:
00005 // \file
00006 // \brief A local rational camera model
00007 // \author Joseph Mundy
00008 // \date February 16, 2008
00009 //
00010 // Rational camera models are defined with respect to global geographic
00011 // coordinates. In many applications it is necessary to project points with
00012 // local 3-d Cartesian coordinates. This camera class incorporates a
00013 // Local Vertical Coordinate System (LVCS) to convert local coordinates
00014 // to geographic coordinates to input to the native geographic RPC model.
00015 
00016 #include <vgl/vgl_fwd.h>
00017 #include <vcl_iostream.h>
00018 #include <vcl_string.h>
00019 #include <vpgl/vpgl_rational_camera.h>
00020 #include <vpgl/vpgl_lvcs.h>
00021 //
00022 //--------------------=== composite rational camera ===---------------------------
00023 //
00024 template <class T>
00025 class vpgl_local_rational_camera : public vpgl_rational_camera<T>
00026 {
00027  public:
00028   //: default constructor
00029   vpgl_local_rational_camera();
00030 
00031   //: Constructor from a rational camera and a lvcs
00032   vpgl_local_rational_camera(vpgl_lvcs const& lvcs,
00033                              vpgl_rational_camera<T> const& rcam);
00034 
00035   //: Constructor from a rational camera and a geographic origin
00036   vpgl_local_rational_camera(T longitude, T latitude, T elevation,
00037                              vpgl_rational_camera<T> const& rcam);
00038 
00039 
00040   virtual ~vpgl_local_rational_camera() {}
00041 
00042   virtual vcl_string type_name() const { return "vpgl_local_rational_camera"; }
00043 
00044   //: Clone `this': creation of a new object and initialization
00045   //  See Prototype pattern
00046   virtual vpgl_local_rational_camera<T>* clone(void) const;
00047 
00048   //: Equality test
00049   inline bool operator==(vpgl_local_rational_camera<T> const &that) const
00050   { return this == &that ||
00051            ( static_cast<vpgl_rational_camera<T> const&>(*this) ==
00052              static_cast<vpgl_rational_camera<T> const&>(that)      &&
00053              this->lvcs() == that.lvcs() );
00054   }
00055 // Mutators/Accessors
00056 
00057 //: set the local vertical coordinate system
00058 void set_lvcs(vpgl_lvcs const& lvcs) {lvcs_ = lvcs;}
00059 
00060 vpgl_lvcs lvcs() const {return lvcs_;}
00061 
00062 //: The generic camera interface. u represents image column, v image row.
00063 virtual void project(const T x, const T y, const T z, T& u, T& v) const;
00064 
00065 // Interface for vnl
00066 
00067 //: Project a world point onto the image
00068 virtual vnl_vector_fixed<T, 2> project(vnl_vector_fixed<T, 3> const& world_point) const;
00069 
00070 // Interface for vgl
00071 
00072 //: Project a world point onto the image
00073 virtual vgl_point_2d<T> project(vgl_point_3d<T> world_point) const;
00074 
00075 
00076 //: print the camera parameters
00077 virtual void print(vcl_ostream& s = vcl_cout) const;
00078 
00079 //: save to file (the lvcs is after the global rational camera parameters)
00080 virtual bool save(vcl_string cam_path);
00081 
00082 
00083 protected:
00084 vpgl_lvcs lvcs_;
00085 };
00086 
00087 //: Creates a local rational camera from a file
00088 // \relatesalso vpgl_local_rational_camera
00089 template <class T>
00090 vpgl_local_rational_camera<T>* read_local_rational_camera(vcl_string cam_path);
00091 
00092 //: Creates a local rational camera from a file
00093 // \relatesalso vpgl_local_rational_camera
00094 template <class T>
00095 vpgl_local_rational_camera<T>* read_local_rational_camera(vcl_istream& istr);
00096 
00097 //: Write to stream
00098 // \relatesalso vpgl_local_rational_camera
00099 template <class T>
00100 vcl_ostream& operator<<(vcl_ostream& s, const vpgl_local_rational_camera<T>& p);
00101 
00102 //: Read from stream
00103 // \relatesalso vpgl_local_rational_camera
00104 template <class T>
00105 vcl_istream& operator>>(vcl_istream& is, vpgl_local_rational_camera<T>& p);
00106 
00107 #define VPGL_LOCAL_RATIONAL_CAMERA_INSTANTIATE(T) extern "please include vgl/vpgl_local_rational_camera.txx first"
00108 
00109 
00110 #endif // vpgl_local_rational_camera_h_
00111