Go to the documentation of this file.00001 #ifndef vpgl_geo_camera_h_
00002 #define vpgl_geo_camera_h_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <vcl_iosfwd.h>
00016 #include <vcl_vector.h>
00017
00018 #include <vpgl/bgeo/bgeo_lvcs_sptr.h>
00019 #include <vpgl/bgeo/bgeo_lvcs.h>
00020 #include <vnl/vnl_matrix.h>
00021
00022 #include <vpgl/vpgl_camera.h>
00023 #include <vsl/vsl_binary_io.h>
00024
00025 #include <vil/file_formats/vil_tiff.h>
00026
00027 class vpgl_geo_camera : public vpgl_camera<double>
00028 {
00029 public:
00030
00031 vpgl_geo_camera();
00032
00033 vpgl_geo_camera(vnl_matrix<double> trans_matrix,
00034 bgeo_lvcs_sptr lvcs,
00035 vcl_vector<vcl_vector<double> > tiepoints)
00036 : trans_matrix_(trans_matrix), is_utm(false), scale_tag_(false) { this->set_lvcs(lvcs); }
00037
00038
00039 vpgl_geo_camera(vpgl_geo_camera const& rhs);
00040
00041 vpgl_geo_camera(vpgl_camera<double> const& rhs);
00042
00043 static bool init_geo_camera(vil_tiff_image* const& geotiff_img,
00044 bgeo_lvcs_sptr lvcs,
00045 vpgl_geo_camera*& camera);
00046
00047 ~vpgl_geo_camera() {}
00048
00049 virtual vcl_string type_name() const { return "vpgl_geo_camera"; }
00050
00051
00052 void set_utm(int utm_zone, unsigned northing) { is_utm=true, utm_zone_=utm_zone; northing_=northing; }
00053
00054 void set_lvcs(bgeo_lvcs_sptr lvcs) {lvcs_ = new bgeo_lvcs(*lvcs); }
00055
00056 void set_scale_format(bool scale_tag) { scale_tag_=scale_tag; }
00057
00058 bgeo_lvcs_sptr const lvcs() {return lvcs_;}
00059
00060
00061
00062 void project(const double x, const double y, const double z, double& u, double& v) const;
00063
00064
00065 void backproject(const double u, const double v, double& x, double& y, double& z);
00066
00067
00068 void translate(double tx, double ty, double z);
00069
00070
00071 double pixel_spacing() { if (scale_tag_) return trans_matrix_[0][0];
00072 else return 1.0; }
00073
00074 bool operator ==(vpgl_geo_camera const& rhs) const;
00075
00076 static bool comp_trans_matrix(double sx1, double sy1, double sz1,
00077 vcl_vector<vcl_vector<double> > tiepoints,
00078 vnl_matrix<double>& trans_matrix,
00079 bool scale_tag = false);
00080
00081
00082 virtual vcl_string is_a() const { return vcl_string("vpgl_geo_camera"); }
00083
00084
00085 virtual bool is_class(vcl_string const& cls) const
00086 { return cls==is_a() || cls==vcl_string("vpgl_geo_camera"); }
00087
00088
00089
00090
00091 virtual void b_write(vsl_b_ostream &os) const;
00092
00093
00094 virtual void b_read(vsl_b_istream &is);
00095
00096
00097 friend vcl_ostream& operator<<(vcl_ostream& s, vpgl_geo_camera const& p);
00098
00099
00100 friend vcl_istream& operator>>(vcl_istream& s, vpgl_geo_camera& p);
00101
00102
00103 void img_to_wgs(const unsigned i, const unsigned j, const unsigned z,
00104 double& lon, double& lat, double& elev);
00105
00106 #if 0
00107
00108 void wgs_to_img(double lon, double lat,
00109 unsigned& i, unsigned& j);
00110 #endif // 0
00111
00112 private:
00113
00114 vnl_matrix<double> trans_matrix_;
00115
00116 bgeo_lvcs_sptr lvcs_;
00117 bool is_utm;
00118 int utm_zone_;
00119 int northing_;
00120 bool scale_tag_;
00121 };
00122
00123 #endif // vpgl_geo_camera_h_