00001 00024 #ifndef __BUNDLE_CAMERA__ 00025 #define __BUNDLE_CAMERA__ 00026 00027 #include <vector> 00028 #include <opencv/cv.h> 00029 #include <string> 00030 #include <fstream> 00031 00032 namespace DVision { 00033 00035 namespace Bundle { 00036 00038 class CameraFile 00039 { 00040 public: 00041 00043 class Camera 00044 { 00045 public: 00047 float f, k1, k2; 00049 cv::Mat R; 00051 cv::Mat t; 00052 00053 public: 00057 Camera(){} 00058 00063 Camera(const std::string &filename) 00064 { 00065 load(filename); 00066 } 00067 00073 void save(const std::string &filename, 00074 const std::string &comment = "") const; 00075 00080 void load(const std::string &filename); 00081 00082 protected: 00083 friend class CameraFile; 00084 00090 void save(std::fstream &f) const; 00091 00097 void load(std::fstream &f); 00098 00099 }; 00100 00101 public: 00107 static void readFile(const std::string &filename, 00108 std::vector<Camera> &cameras); 00109 00115 static void saveFile(const std::string &filename, 00116 const std::vector<Camera> &cameras); 00117 00118 protected: 00119 00126 static void readFromStream(std::fstream &f, int N, 00127 std::vector<Camera> &cameras); 00128 00134 static void saveToStream(std::fstream &f, 00135 const std::vector<Camera> &cameras); 00136 00137 }; 00138 00139 } 00140 } 00141 00142 #endif 00143