vpgl_local_rational_camera.h
Go to the documentation of this file.
1 // This is core/vpgl/vpgl_local_rational_camera.h
2 #ifndef vpgl_local_rational_camera_h_
3 #define vpgl_local_rational_camera_h_
4 //:
5 // \file
6 // \brief A local rational camera model
7 // \author Joseph Mundy
8 // \date February 16, 2008
9 //
10 // Rational camera models are defined with respect to global geographic
11 // coordinates. In many applications it is necessary to project points with
12 // local 3-d Cartesian coordinates. This camera class incorporates a
13 // Local Vertical Coordinate System (LVCS) to convert local coordinates
14 // to geographic coordinates to input to the native geographic RPC model.
15 
16 #include <iostream>
17 #include <string>
18 #include <vgl/vgl_fwd.h>
19 #ifdef _MSC_VER
20 # include <vcl_msvc_warnings.h>
21 #endif
23 #include <vpgl/vpgl_lvcs.h>
24 //
25 //--------------------=== composite rational camera ===---------------------------
26 //
27 template <class T>
29 {
30  public:
31  //: default constructor
33 
34  //: Constructor from a rational camera and a lvcs
36  vpgl_rational_camera<T> const& rcam);
37 
38  //: Constructor from a rational camera and a geographic origin
39  vpgl_local_rational_camera(T longitude, T latitude, T elevation,
40  vpgl_rational_camera<T> const& rcam);
41 
42 
43  ~vpgl_local_rational_camera() override = default;
44 
45  std::string type_name() const override { return "vpgl_local_rational_camera"; }
46 
47  //: Clone `this': creation of a new object and initialization
48  // See Prototype pattern
49  vpgl_local_rational_camera<T>* clone(void) const override;
50 
51  //: Equality test
52  inline bool operator==(vpgl_local_rational_camera<T> const &that) const
53  { return this == &that ||
54  ( static_cast<vpgl_rational_camera<T> const&>(*this) ==
55  static_cast<vpgl_rational_camera<T> const&>(that) &&
56  this->lvcs() == that.lvcs() );
57  }
58 // Mutators/Accessors
59 
60 //: set the local vertical coordinate system
61 void set_lvcs(vpgl_lvcs const& lvcs) {lvcs_ = lvcs;}
62 
63 vpgl_lvcs lvcs() const {return lvcs_;}
64 
65 //: The generic camera interface. u represents image column, v image row.
66 void project(const T x, const T y, const T z, T& u, T& v) const override;
67 
68 // Interface for vnl
69 
70 //: Project a world point onto the image
71 vnl_vector_fixed<T, 2> project(vnl_vector_fixed<T, 3> const& world_point) const override;
72 
73 // Interface for vgl
74 
75 //: Project a world point onto the image
76 vgl_point_2d<T> project(vgl_point_3d<T> world_point) const override;
77 
78 
79 //: print the camera parameters
80 void print(std::ostream& s = std::cout) const override;
81 
82 //: save to file (the lvcs is after the global rational camera parameters)
83 bool save(std::string cam_path) override;
84 
85 
86 protected:
88 };
89 
90 //: Creates a local rational camera from a file
91 // \relatesalso vpgl_local_rational_camera
92 template <class T>
94 
95 //: Creates a local rational camera from a stream (RPB format)
96 // \relatesalso vpgl_local_rational_camera
97 template <class T>
99 
100 //: read camera from txt file (small sat format)
101 template <class T>
103 
104 //: Write to stream
105 // \relatesalso vpgl_local_rational_camera
106 template <class T>
107 std::ostream& operator<<(std::ostream& s, const vpgl_local_rational_camera<T>& p);
108 
109 //: Read from stream
110 // \relatesalso vpgl_local_rational_camera
111 template <class T>
112 std::istream& operator>>(std::istream& is, vpgl_local_rational_camera<T>& p);
113 
114 #define VPGL_LOCAL_RATIONAL_CAMERA_INSTANTIATE(T) extern "please include vgl/vpgl_local_rational_camera.hxx first"
115 
116 
117 #endif // vpgl_local_rational_camera_h_
void project(const T x, const T y, const T z, T &u, T &v) const override
The generic camera interface. u represents image column, v image row.
A geographic coordinate system.
std::istream & operator>>(std::istream &is, vpgl_local_rational_camera< T > &p)
Read from stream.
vpgl_local_rational_camera< T > * clone(void) const override
Clone ‘this’: creation of a new object and initialization.
void print(std::ostream &s=std::cout) const override
print the camera parameters.
vpgl_local_rational_camera< T > * read_local_rational_camera(std::string cam_path)
Creates a local rational camera from a file.
A camera model based on ratios of cubic polynomials.
vpgl_local_rational_camera< T > * read_local_rational_camera_from_txt(std::string cam_path)
read camera from txt file (small sat format).
bool operator==(vpgl_local_rational_camera< T > const &that) const
Equality test.
std::string type_name() const override
class identity functions for casting.
~vpgl_local_rational_camera() override=default
std::ostream & operator<<(std::ostream &s, const vpgl_local_rational_camera< T > &p)
Write to stream.
void set_lvcs(vpgl_lvcs const &lvcs)
set the local vertical coordinate system.
vpgl_local_rational_camera()
default constructor.
bool save(std::string cam_path) override
save to file (the lvcs is after the global rational camera parameters).