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