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