00001 // ZhangCamera.cpp: implementation of the ZhangCamera class. 00002 // 00003 ////////////////////////////////////////////////////////////////////// 00004 00005 #include "bcal_zhang_camera_node.h" 00006 #include "bcal_camera.h" 00007 #include <vcl_iostream.h> 00008 #include <vcl_fstream.h> 00009 00010 ////////////////////////////////////////////////////////////////////// 00011 // Construction/Destruction 00012 ////////////////////////////////////////////////////////////////////// 00013 00014 bcal_zhang_camera_node::bcal_zhang_camera_node(int id) : bcal_camera_node(id) 00015 { 00016 // build lens distortion model 00017 vcl_vector<bool> flags(7, false); 00018 flags[0] = true; 00019 flags[1] = true; 00020 cam_ -> set_lens_model(flags); 00021 00022 // allocate space to store features. 00023 point_lists_ptr_ = 0; 00024 } 00025 00026 bcal_zhang_camera_node::~bcal_zhang_camera_node() 00027 { 00028 removeData(); 00029 } 00030 00031 void bcal_zhang_camera_node::set_beat(vcl_vector<double> const& new_beat) 00032 { 00033 bcal_camera_node::set_beat(new_beat); 00034 00035 // allocate space to store data 00036 if (point_lists_ptr_) 00037 this->removeData(); 00038 00039 point_lists_ptr_ = new vcl_vector< vgl_homg_point_2d<double> > [num_views_]; 00040 } 00041 00042 int bcal_zhang_camera_node::readData(const char *fname, int iView) 00043 { 00044 vcl_ifstream in(fname); 00045 00046 if (!in){ 00047 vcl_cout<<" cannot open the file: "<<fname << vcl_endl; 00048 return 1; 00049 } 00050 00051 if (num_views_<=0){ 00052 vcl_cerr<<" not memory allocated for storing\n"; 00053 return 2; 00054 } 00055 00056 if (num_views_<iView){ 00057 vcl_cerr<<"view index out of range of beat\n"; 00058 return 3; 00059 } 00060 00061 if (point_lists_ptr_[iView].size() != 0){ 00062 point_lists_ptr_[iView].clear(); 00063 } 00064 00065 while (!in.eof()){ 00066 double u, v; 00067 in>>u>>v; 00068 vgl_homg_point_2d<double> pt(u, v); 00069 point_lists_ptr_[iView].push_back(pt); 00070 } 00071 return 0; 00072 } 00073 00074 int bcal_zhang_camera_node::removeData() 00075 { 00076 if (point_lists_ptr_) 00077 delete [] point_lists_ptr_; 00078 point_lists_ptr_ = 0; 00079 00080 return 0; 00081 } 00082 00083 int bcal_zhang_camera_node::read_data(vcl_vector< vgl_homg_point_2d<double> > & plist, int iframe) 00084 { 00085 point_lists_ptr_[iframe] = plist; 00086 00087 return 0; 00088 }
1.5.1