core/vpgl/algo/vpgl_rational_adjust.h
Go to the documentation of this file.
00001 // This is core/vpgl/algo/vpgl_rational_adjust.h
00002 #ifndef vpgl_rational_adjust_h_
00003 #define vpgl_rational_adjust_h_
00004 //:
00005 // \file
00006 // \brief Adjust 3-d offset and scale to align rational cameras to geolocations
00007 // \author J. L. Mundy
00008 // \date August 06, 2007
00009 
00010 #include <vcl_vector.h>
00011 #include <vnl/vnl_vector.h>
00012 #include <vnl/vnl_least_squares_function.h>
00013 #include <vpgl/vpgl_rational_camera.h>
00014 #include <vgl/vgl_point_2d.h>
00015 #include <vgl/vgl_point_3d.h>
00016 
00017 //:
00018 // The 3-d offset and scale parameters of rational cameras typically
00019 // must be adjusted to compensate for errors in geographic alignment.
00020 // This algorithm adjusts these parameters to give the smallest
00021 // projection error. That is, the error between the true image location
00022 // and the projected 3-d world point corresponding to that location.
00023 
00024 class vpgl_adjust_lsqr : public vnl_least_squares_function
00025 {
00026  public:
00027   //: Constructor
00028   // \note image points are not homogeneous because require finite points to measure projection error
00029   vpgl_adjust_lsqr(vpgl_rational_camera<double>  const& rcam,
00030                    vcl_vector<vgl_point_2d<double> > const& img_pts,
00031                    vcl_vector<vgl_point_3d<double> > const& geo_pts,
00032                    unsigned num_unknowns, unsigned num_residuals);
00033 
00034   //: Destructor
00035   virtual ~vpgl_adjust_lsqr() {}
00036 
00037   //: The main function.
00038   //  Given the parameter vector x, compute the vector of residuals fx.
00039   //  fx has been sized appropriately before the call.
00040   virtual void f(vnl_vector<double> const& x, vnl_vector<double>& fx);
00041 
00042 #if 0
00043   //: Called after each LM iteration to print debugging etc.
00044   virtual void trace(int iteration, vnl_vector<double> const& x, vnl_vector<double> const& fx);
00045 #endif
00046 
00047  protected:
00048   unsigned num_corrs_;
00049   vpgl_rational_camera<double> rcam_;
00050   vcl_vector<vgl_point_2d<double> > img_pts_;
00051   vcl_vector<vgl_point_3d<double> > geo_pts_;
00052 };
00053 
00054 class vpgl_rational_adjust
00055 {
00056  public:
00057   ~vpgl_rational_adjust(){}
00058 
00059   static bool adjust(vpgl_rational_camera<double> const& initial_rcam,
00060                      vcl_vector<vgl_point_2d<double> > img_pts,
00061                      vcl_vector<vgl_point_3d<double> > geo_pts,
00062                      vpgl_rational_camera<double> & adj_rcam);
00063  protected:
00064   vpgl_rational_adjust();
00065 };
00066 
00067 
00068 #endif // vpgl_rational_adjust_h_