vpgl_backproject_dem.h
Go to the documentation of this file.
1 // This is core/vpgl/algo/vpgl_backproject_dem.h
2 #ifndef vpgl_backproject_dem_h_
3 #define vpgl_backproject_dem_h_
4 //:
5 // \file
6 // \brief Camera backproject functions involving geotiff DEMs
7 // \author J. L. Mundy
8 // \date Oct 22, 2016
9 //
10 // \verbatim
11 // Modifications NONE
12 // \endverbatim
13 // The camera is assumed to project lon, lat and elevation to u and v
14 // The units are degrees and meters with WGS84 datum
15 //
16 #include <vector>
17 #include <vgl/vgl_fwd.h>
19 #include <vnl/vnl_double_2.h>
20 #include <vnl/vnl_double_3.h>
21 #include <vgl_point_3d.h>
22 #include <vil/vil_image_resource_sptr.h>
23 #include <vil/vil_image_view.h>
24 class vpgl_geo_camera; //forward declare for ptr
26 {
27  public:
28  //: default constructor not allowed
29  vpgl_backproject_dem(vil_image_resource_sptr const& dem, double zmin=0.0, double zmax=-1.0);
31 
32  //: turn on/off messages (default not verbose)
33  void set_verbose(bool verbose){verbose_ = verbose;}
34 
35  //center of the DEM - useful for initializing non-linear search
37 
38  //: elevation bounds of the DEM (with tail removal)
39  double zmax() const {return z_max_;}
40  double zmin() const {return z_min_;}
41 
42  //: geographic corners of the DEM - useful for bounding valid image regions
43  std::vector<vgl_point_3d<double> > dem_corners() const {return dem_corners_;}
44 
45  /// General camera - typically a RPC camera
46  //:Backproject an image point onto a geotiff dem, start with initial_guess
47  // use local ray with origin and dir from backprojection onto max_z and min_z planes
48  bool bproj_dem(const vpgl_camera<double>* cam,
49  vnl_double_2 const& image_point,
50  double max_z, double min_z,
51  vnl_double_3 const& initial_guess,
52  vnl_double_3& world_point,
53  double error_tol = 1.0);
54 
55  // === vgl interface ===
56 
57  //:Backproject an image point onto a geotiff dem, start with initial_guess
58  // use local ray with origin and dir from backprojection onto max_z and min_z planes
59  bool bproj_dem(const vpgl_camera<double>* cam,
60  vgl_point_2d<double> const& image_point,
61  double max_z, double min_z,
62  vgl_point_3d<double> const& initial_guess,
63  vgl_point_3d<double>& world_point,
64  double error_tol = 1.0);
65 
66 
67 // +++ concrete rational camera interfaces +++
68 
69 // === vnl interface ===
70 
71  //:Backproject an image point onto a plane, start with initial_guess
72  // use local ray with origin and dir from backprojection onto rcam's z bounds
73  bool bproj_dem(vpgl_rational_camera<double> const& rcam,
74  vnl_double_2 const& image_point,
75  double max_z, double min_z,
76  vnl_double_3 const& initial_guess,
77  vnl_double_3& world_point,
78  double error_tol = 0.05);
79 
80  // ==== vgl interface ===
81 
82  //:Backproject an image point onto a plane, start with initial_guess
83  // use local ray with origin and dir from backprojection onto rcam's z bounds
84  bool bproj_dem(vpgl_rational_camera<double> const& rcam,
85  vgl_point_2d<double> const& image_point,
86  double max_z, double min_z,
87  vgl_point_3d<double> const& initial_guess,
88  vgl_point_3d<double>& world_point,
89  double error_tol = 0.05);
90  private:
91  bool verbose_;
92  double min_samples_;
93  double tail_fract_;
94  vil_image_resource_sptr dem_;
95  vil_image_view<float> dem_view_;
98  std::vector<vgl_point_3d<double> > dem_corners_;
99  //: bounds of the DEM
100  double z_min_;
101  double z_max_;
102 };
103 
104 #endif // vpgl_backproject_dem_h_
vil_image_view< float > dem_view_
A camera model based on ratios of cubic polynomials.
vpgl_geo_camera * geo_cam_
vgl_point_3d< double > geo_center_
void set_verbose(bool verbose)
turn on/off messages (default not verbose).
double z_min_
bounds of the DEM.
vgl_point_3d< double > geo_center() const
vpgl_backproject_dem(vil_image_resource_sptr const &dem, double zmin=0.0, double zmax=-1.0)
default constructor not allowed.
std::vector< vgl_point_3d< double > > dem_corners_
bool bproj_dem(const vpgl_camera< double > *cam, vnl_double_2 const &image_point, double max_z, double min_z, vnl_double_3 const &initial_guess, vnl_double_3 &world_point, double error_tol=1.0)
General camera - typically a RPC camera.
double zmax() const
elevation bounds of the DEM (with tail removal).
std::vector< vgl_point_3d< double > > dem_corners() const
geographic corners of the DEM - useful for bounding valid image regions.
vil_image_resource_sptr dem_