core/vpgl/algo/vpgl_rational_adjust_onept.h
Go to the documentation of this file.
00001 // This is core/vpgl/algo/vpgl_rational_adjust_onept.h
00002 #ifndef vpgl_rational_adjust_onept_h_
00003 #define vpgl_rational_adjust_onept_h_
00004 //:
00005 // \file
00006 // \brief Adjust image offsets to register a set of rational cameras
00007 // \author J. L. Mundy
00008 // \date July 29, 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_vector_2d.h>
00016 #include <vgl/vgl_point_2d.h>
00017 #include <vgl/vgl_point_3d.h>
00018 
00019 //:
00020 // The image offsets of rational cameras typically must be adjusted to
00021 // compensate for errors in geographic alignment. This algorithm finds
00022 // a set of minimum translations that registers the input set of images.
00023 // After registration, the images have geographically corresponding rational
00024 // cameras. That is, a visible 3-d point will project into its corresponding
00025 // image location in all the images.
00026 
00027 class vpgl_z_search_lsqr : public vnl_least_squares_function
00028 {
00029  public:
00030   //: Constructor
00031   vpgl_z_search_lsqr(vcl_vector<vpgl_rational_camera<double> > const& cams,
00032                      vcl_vector<vgl_point_2d<double> > const& image_pts,
00033                      vgl_point_3d<double> const& initial_pt);
00034   //: Destructor
00035   virtual ~vpgl_z_search_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& elevation,
00041                  vnl_vector<double>& projection_error);
00042   double xm() const {return xm_;}
00043   double ym() const {return ym_;}
00044  protected:
00045   vpgl_z_search_lsqr();//not valid
00046   vgl_point_3d<double> initial_pt_;
00047   vcl_vector<vpgl_rational_camera<double> > cameras_; //cameras
00048   vcl_vector<vgl_point_2d<double> > image_pts_; //image points
00049   double xm_, ym_;
00050 };
00051 
00052 
00053 class vpgl_rational_adjust_onept
00054 {
00055  public:
00056   ~vpgl_rational_adjust_onept() {}
00057 
00058   static bool
00059   find_intersection_point(vcl_vector<vpgl_rational_camera<double> > const& cams,
00060                           vcl_vector<vgl_point_2d<double> > const& corrs,
00061                           vgl_point_3d<double>& p_3d);
00062 
00063   static bool
00064   refine_intersection_pt(vcl_vector<vpgl_rational_camera<double> > const& cams,
00065                          vcl_vector<vgl_point_2d<double> > const& image_pts,
00066                          vgl_point_3d<double> const& initial_pt,
00067                          vgl_point_3d<double>& final_pt);
00068 
00069   static bool adjust(vcl_vector<vpgl_rational_camera<double> > const& cams,
00070                      vcl_vector<vgl_point_2d<double> > const& corrs,
00071                      vcl_vector<vgl_vector_2d<double> >& cam_translations,
00072                      vgl_point_3d<double>& intersection);
00073 
00074  protected:
00075   vpgl_rational_adjust_onept();
00076 };
00077 
00078 
00079 #endif // vpgl_rational_adjust_onept_h_