00001 #ifndef brct_plane_calibrator_h_ 00002 #define brct_plane_calibrator_h_ 00003 //: 00004 // \file 00005 // \brief A class to compute homographies from a world plane to a camera plane 00006 // 00007 // \author J.L. Mundy 00008 // \verbatim 00009 // Initial version Feb. 2004 00010 // \endverbatim 00011 // 00012 ////////////////////////////////////////////////////////////////////// 00013 00014 #include <vcl_vector.h> 00015 #include <vcl_string.h> 00016 #include <vgl/vgl_point_2d.h> 00017 #include <vgl/vgl_homg_point_2d.h> 00018 #include <vgl/algo/vgl_h_matrix_2d.h> 00019 #include <brct/brct_plane_corr_sptr.h> 00020 00021 class brct_plane_calibrator 00022 { 00023 public: 00024 enum z_pos {Z_BACK=0, Z_FRONT}; 00025 enum cam_no {LEFT=0, RIGHT}; 00026 brct_plane_calibrator(); 00027 ~brct_plane_calibrator(); 00028 00029 //Accessors 00030 00031 int n_points(int plane) const {return pts_3d_[plane].size();} 00032 vcl_vector<vgl_homg_point_2d<double> > 00033 points_3d(int plane) const {return pts_3d_[plane];} 00034 vgl_homg_point_2d<double> p3d(const int plane, const int i) 00035 {return pts_3d_[plane][i];} 00036 brct_plane_corr_sptr corr(const int plane, const int i){return corrs_[plane][i];} 00037 00038 //Mutators 00039 00040 //: read the visible marker points on a set of 3-d world planes 00041 void read_data(vcl_string const& point3d_file); 00042 //: set the image size for a given view 00043 bool set_image_size(const int cam, const int width, const int height); 00044 00045 // Utility functions 00046 00047 bool compute_initial_homographies(); 00048 bool compute_homographies(); 00049 bool write_corrs(vcl_string const& corrs_file); 00050 bool read_corrs(vcl_string const& corrs_file); 00051 bool write_homographies(vcl_string const& homography_file); 00052 vcl_vector<vgl_point_2d<double> > 00053 projected_3d_points_initial(const int plane, const int cam); 00054 vcl_vector<vgl_point_2d<double> > 00055 projected_3d_points(const int plane, const int cam); 00056 protected: 00057 //local utility functions 00058 00059 void init_corrs(); 00060 00061 //members 00062 00063 //:camera info 00064 vcl_vector<int> cam_width_; 00065 vcl_vector<int> cam_height_; 00066 00067 //world plane points 00068 vcl_vector<vcl_vector<vgl_homg_point_2d<double> > > pts_3d_;//points on 3-d planes 00069 00070 //: correspondence data 00071 //world plane image correspondences 00072 vcl_vector<vcl_vector<brct_plane_corr_sptr> > corrs_; 00073 00074 //: 3-d loaded flag 00075 bool points_3d_valid_; 00076 //: initial_homographies flag 00077 bool initial_homographies_valid_; 00078 00079 //: debug flag 00080 bool debug_; 00081 double z_back_; 00082 double z_front_; 00083 //world plane camera 00084 vcl_vector< vcl_vector<vgl_h_matrix_2d<double> > > initial_homographies_; 00085 vcl_vector< vcl_vector<vgl_h_matrix_2d<double> > > current_homographies_; 00086 }; 00087 00088 #endif // brct_plane_calibrator_h_
1.7.5.1