vpgl_rational_adjust_onept.h
Go to the documentation of this file.
1 // This is core/vpgl/algo/vpgl_rational_adjust_onept.h
2 #ifndef vpgl_rational_adjust_onept_h_
3 #define vpgl_rational_adjust_onept_h_
4 //:
5 // \file
6 // \brief Adjust image offsets to register a set of rational cameras
7 // \author J. L. Mundy
8 // \date July 29, 2007
9 //
10 // \verbatim
11 // Modifications
12 // Yi Dong Jun-2015 added new function to optimize the 3-d point intersection search by a user-defined initial guess
13 // \endverbatim
14 
15 #include <vector>
16 #ifdef _MSC_VER
17 # include <vcl_msvc_warnings.h>
18 #endif
19 #include <vnl/vnl_vector.h>
22 #include <vgl/vgl_vector_2d.h>
23 #include <vgl/vgl_point_2d.h>
24 #include <vgl/vgl_point_3d.h>
25 
26 //:
27 // The image offsets of rational cameras typically must be adjusted to
28 // compensate for errors in geographic alignment. This algorithm finds
29 // a set of minimum translations that registers the input set of images.
30 // After registration, the images have geographically corresponding rational
31 // cameras. That is, a visible 3-d point will project into its corresponding
32 // image location in all the images.
33 
35 {
36  public:
37  //: Constructor
39  std::vector<float> cam_weights,
40  std::vector<vgl_point_2d<double> > image_pts,
41  vgl_point_3d<double> const& initial_pt,
42  double const& relative_diameter = 1.0);
43  //: Destructor
44  ~vpgl_z_search_lsqr() override = default;
45 
46  //: The main function.
47  // Given the parameter vector x, compute the vector of residuals fx.
48  // fx has been sized appropriately before the call.
49  void f(vnl_vector<double> const& elevation,
50  vnl_vector<double>& projection_error) override;
51  double xm() const {return xm_;}
52  double ym() const {return ym_;}
53  protected:
54  vpgl_z_search_lsqr();//not valid
56  std::vector<vpgl_rational_camera<double> > cameras_; //cameras
57  std::vector<float> cam_weights_;
58  std::vector<vgl_point_2d<double> > image_pts_; //image points
59  double xm_, ym_;
61 };
62 
63 
65 {
66  public:
67  ~vpgl_rational_adjust_onept() = default;
68 
69  static bool
70  find_intersection_point(std::vector<vpgl_rational_camera<double> > const& cams,
71  std::vector<float> const& cam_weights,
72  std::vector<vgl_point_2d<double> > const& corrs,
73  vgl_point_3d<double>& p_3d);
74 
75  static bool
76  find_intersection_point(std::vector<vpgl_rational_camera<double> > const& cams,
77  std::vector<float> const& cam_weights,
78  std::vector<vgl_point_2d<double> > const& corrs,
79  vgl_point_3d<double> const& initial_pt,
80  double const& zmin,
81  double const& zmax,
82  vgl_point_3d<double> & p_3d,
83  double const& relative_diameter = 1.0);
84 
85  static bool
86  refine_intersection_pt(std::vector<vpgl_rational_camera<double> > const& cams,
87  std::vector<float> const& cam_weights,
88  std::vector<vgl_point_2d<double> > const& image_pts,
89  vgl_point_3d<double> const& initial_pt,
90  vgl_point_3d<double>& final_pt,
91  double const& relative_diameter = 1.0);
92 
93  static bool adjust(std::vector<vpgl_rational_camera<double> > const& cams,
94  std::vector<vgl_point_2d<double> > const& corrs,
95  std::vector<vgl_vector_2d<double> >& cam_translations,
97 
98  static bool adjust(std::vector<vpgl_rational_camera<double> > const& cams,
99  std::vector<vgl_point_2d<double> > const& corrs,
100  vgl_point_3d<double> const& initial_pt,
101  double const& zmin,
102  double const& zmax,
103  std::vector<vgl_vector_2d<double> >& cam_translations,
105  double const& relative_diameter = 1.0);
106 
107  // pass a weight for each camera, the weights should add up to 1.0
108  static bool adjust_with_weights(std::vector<vpgl_rational_camera<double> > const& cams, std::vector<float> weights,
109  std::vector<vgl_point_2d<double> > const& corrs,
110  std::vector<vgl_vector_2d<double> >& cam_translations,
112 
113  static bool adjust_with_weights(std::vector<vpgl_rational_camera<double> > const& cams, std::vector<float> const& weights,
114  std::vector<vgl_point_2d<double> > const& corrs,
115  vgl_point_3d<double> const& initial_pt,
116  double const& zmin,
117  double const& zmax,
118  std::vector<vgl_vector_2d<double> >& cam_translations,
120  double const& relative_diameter = 1.0);
121 
122  protected:
124 };
125 
126 
127 #endif // vpgl_rational_adjust_onept_h_
static bool adjust(std::vector< vpgl_rational_camera< double > > const &cams, std::vector< vgl_point_2d< double > > const &corrs, std::vector< vgl_vector_2d< double > > &cam_translations, vgl_point_3d< double > &intersection)
static bool adjust_with_weights(std::vector< vpgl_rational_camera< double > > const &cams, std::vector< float > weights, std::vector< vgl_point_2d< double > > const &corrs, std::vector< vgl_vector_2d< double > > &cam_translations, vgl_point_3d< double > &intersection)
vgl_homg_point_3d< Type > intersection(l const &l1, l const &l2)
The image offsets of rational cameras typically must be adjusted to compensate for errors in geograph...
A camera model based on ratios of cubic polynomials.
void f(vnl_vector< double > const &elevation, vnl_vector< double > &projection_error) override
The main function.
~vpgl_rational_adjust_onept()=default
static bool find_intersection_point(std::vector< vpgl_rational_camera< double > > const &cams, std::vector< float > const &cam_weights, std::vector< vgl_point_2d< double > > const &corrs, vgl_point_3d< double > &p_3d)
vgl_point_3d< double > initial_pt_
std::vector< float > cam_weights_
std::vector< vgl_point_2d< double > > image_pts_
static bool refine_intersection_pt(std::vector< vpgl_rational_camera< double > > const &cams, std::vector< float > const &cam_weights, std::vector< vgl_point_2d< double > > const &image_pts, vgl_point_3d< double > const &initial_pt, vgl_point_3d< double > &final_pt, double const &relative_diameter=1.0)
~vpgl_z_search_lsqr() override=default
Destructor.
std::vector< vpgl_rational_camera< double > > cameras_