core/vpgl/algo/vpgl_ba_fixed_k_lsqr.h
Go to the documentation of this file.
00001 // This is vpgl/algo/vpgl_ba_fixed_k_lsqr.h
00002 #ifndef vpgl_ba_fixed_k_lsqr_h_
00003 #define vpgl_ba_fixed_k_lsqr_h_
00004 //:
00005 // \file
00006 // \brief Bundle adjustment sparse least squares class for fixed intrinsics
00007 // \author Matt Leotta
00008 // \date April 18, 2005
00009 // \verbatim
00010 //  Modifications
00011 //   Mar 23, 2010  MJL - Split off base class and moved to its own file
00012 // \endverbatim
00013 
00014 #include <vpgl/algo/vpgl_bundle_adjust_lsqr.h>
00015 
00016 
00017 //: a class for bundle adjustment with fixed intrinsic parameters
00018 class vpgl_ba_fixed_k_lsqr : public vpgl_bundle_adjust_lsqr
00019 {
00020  public:
00021   //: Constructor
00022   // \note image points are not homogeneous because they require finite points
00023   //       to measure projection error
00024   vpgl_ba_fixed_k_lsqr(const vcl_vector<vpgl_calibration_matrix<double> >& K,
00025                        const vcl_vector<vgl_point_2d<double> >& image_points,
00026                        const vcl_vector<vcl_vector<bool> >& mask);
00027 
00028   //: Constructor
00029   //  Each image point is assigned an inverse covariance (error projector) matrix
00030   // \note image points are not homogeneous because they require finite points
00031   //       to measure projection error
00032   vpgl_ba_fixed_k_lsqr(const vcl_vector<vpgl_calibration_matrix<double> >& K,
00033                        const vcl_vector<vgl_point_2d<double> >& image_points,
00034                        const vcl_vector<vnl_matrix<double> >& inv_covars,
00035                        const vcl_vector<vcl_vector<bool> >& mask);
00036 
00037   // Destructor
00038   virtual ~vpgl_ba_fixed_k_lsqr() {}
00039 
00040 
00041   //: compute the Jacobian Aij
00042   virtual void jac_Aij(unsigned int i,
00043                        unsigned int j,
00044                        vnl_double_3x4 const& Pi,
00045                        vnl_vector<double> const& ai,
00046                        vnl_vector<double> const& bj,
00047                        vnl_vector<double> const& c,
00048                        vnl_matrix<double>& Aij);
00049 
00050   //: compute the Jacobian Bij
00051   virtual void jac_Bij(unsigned int i,
00052                        unsigned int j,
00053                        vnl_double_3x4 const& Pi,
00054                        vnl_vector<double> const& ai,
00055                        vnl_vector<double> const& bj,
00056                        vnl_vector<double> const& c,
00057                        vnl_matrix<double>& Bij);
00058 
00059   //: compute the Jacobian Cij
00060   virtual void jac_Cij(unsigned int i,
00061                        unsigned int j,
00062                        vnl_double_3x4 const& Pi,
00063                        vnl_vector<double> const& ai,
00064                        vnl_vector<double> const& bj,
00065                        vnl_vector<double> const& c,
00066                        vnl_matrix<double>& Cij);
00067 
00068 
00069   //: construct the \param j-th perspective camera from a pointer to the j-th parameters of \param b and parameters \param c
00070   virtual vgl_homg_point_3d<double>
00071   param_to_point(int j,
00072                  const double* bj,
00073                  const vnl_vector<double>& c) const;
00074 
00075   //: construct the \param j-th perspective camera from a pointer to the j-th parameters of \param b and parameters \param c
00076   virtual vnl_vector_fixed<double,4>
00077   param_to_pt_vector(int j,
00078                      const double* bj,
00079                      const vnl_vector<double>& c) const;
00080 
00081   //: construct the \param i-th perspective camera from a pointer to the i-th parameters of \param a and parameters \param c
00082   virtual vpgl_perspective_camera<double>
00083   param_to_cam(int i,
00084                const double* ai,
00085                const vnl_vector<double>& c) const;
00086 
00087   //: compute a 3x4 camera matrix of camera \param i from a pointer to the i-th parameters of \param a and parameters \param c
00088   virtual vnl_double_3x4
00089   param_to_cam_matrix(int i,
00090                       const double* ai,
00091                       const vnl_vector<double>& c) const;
00092 
00093 
00094   //: Create the parameter vector \p a from a vector of cameras
00095   static vnl_vector<double>
00096   create_param_vector(const vcl_vector<vpgl_perspective_camera<double> >& cameras);
00097 
00098   //: Create the parameter vector \p b from a vector of 3D points
00099   static vnl_vector<double>
00100   create_param_vector(const vcl_vector<vgl_point_3d<double> >& world_points);
00101 
00102 
00103  protected:
00104   //: The fixed internal camera calibration
00105   vcl_vector<vpgl_calibration_matrix<double> > K_;
00106   //: The fixed internal camera calibration in matrix form
00107   vcl_vector<vnl_double_3x3> Km_;
00108 };
00109 
00110 
00111 #endif // vpgl_ba_fixed_k_lsqr_h_