contrib/gel/mrc/vpgl/vpgl_local_rational_camera.h
Go to the documentation of this file.
00001 // This is gel/mrc/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 wiht
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/bgeo/bgeo_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(bgeo_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         // Mutators/Accessors
00049 
00050   //: set the local vertical coordinate system
00051   void set_lvcs(bgeo_lvcs const& lvcs){lvcs_ = lvcs;}
00052 
00053   bgeo_lvcs lvcs(){return lvcs_;}
00054 
00055   //: The generic camera interface. u represents image column, v image row.
00056   virtual void project(const T x, const T y, const T z, T& u, T& v) const;
00057 
00058         // Interface for vnl
00059 
00060   //: Project a world point onto the image
00061   virtual vnl_vector_fixed<T, 2> project(vnl_vector_fixed<T, 3> const& world_point) const;
00062 
00063         // Interface for vgl
00064 
00065   //: Project a world point onto the image
00066   virtual vgl_point_2d<T> project(vgl_point_3d<T> world_point) const;
00067 
00068 
00069   //: print the camera parameters
00070   virtual void print(vcl_ostream& s = vcl_cout) const;
00071 
00072   //: save to file (the lvcs is after the global rational camera parameters)
00073   virtual bool save(vcl_string cam_path);
00074 
00075   // binary IO
00076 
00077   //: Binary save self to stream.
00078   virtual void b_write(vsl_b_ostream &os) const;
00079 
00080   //: Binary load self from stream.
00081   virtual void b_read(vsl_b_istream &is);
00082 
00083  protected:
00084   bgeo_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