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