CameraBridgeFactory.cpp
Go to the documentation of this file.
00001 
00033 #include "CameraBridge.h"
00034 #include "CameraBridgeFactory.h"
00035 #include <string>
00036 
00037 // ----------------------------------------------------------------------------
00038 
00039 const std::string CameraBridgeFactory::m_camera_names[NCameras] =
00040 {
00041         "pike", "unibrain", "unibrain_monoslam", "sony_test", "gazebo_sim",
00042         "unibrain_rectified", "unibrain_bayer","kinect"
00043 };
00044 
00045 // ----------------------------------------------------------------------------
00046 
00047 CameraBridge CameraBridgeFactory::Create(const std::string& model)
00048 {
00049 
00050         if(model == ""){
00051                 // default camera
00052                 return CameraBridge();
00053                 //return CameraBridge(CameraBridge::BW);
00054 
00055         }else if(model == m_camera_names[0]){ // pike
00056                 // Pike camera
00057                 return CameraBridge();
00058                 //return CameraBridge(CameraBridge::BW);
00059 
00060         }else if(model == m_camera_names[1]){ // the unibrain wide angle lens camera
00061                 // pixel units
00062                 const float s = 2.f; // params are for 320x240, but images are at 640x480
00063                 const float cx = 171.78f * s; //171.95f * s;
00064                 const float cy = 127.41f  * s; //127.69f * s;
00065                 const float f = 196.8214f * s; //195.7243f * s;
00066                 const float k1 = -0.3421f;
00067                 const float k2 = 0.1468f;
00068                 const int w = 640;
00069                 const int h = 480;
00070 
00071                 //return CameraBridge(CameraBridge::BAYER_BG, w, h,
00072                 //      cx, cy, f, f, k1, k2, 0.f, 0.f);
00073                 return CameraBridge(w, h,
00074                         cx, cy, f, f, k1, k2, 0.f, 0.f);
00075 
00076         }else if(model == m_camera_names[2]){ // unibrain (wide angle lens) but
00077                 // with the monoslam configuration (320x240 with bayer corrected)
00078 
00079                 const float s = 1.f; // params are for 320x240
00080                 const float cx = 171.78f * s; //171.95f * s;
00081                 const float cy = 127.41f  * s; //127.69f * s;
00082                 const float f = 196.8214f * s; //195.7243f * s;
00083                 const float k1 = -0.3421f;
00084                 const float k2 = 0.1468f;
00085                 const int w = 320;
00086                 const int h = 240;
00087 
00088                 //return CameraBridge(CameraBridge::BW, w, h,
00089                 //      cx, cy, f, f, k1, k2, 0.f, 0.f);
00090                 return CameraBridge(w, h,
00091                         cx, cy, f, f, k1, k2, 0.f, 0.f);
00092 
00093   }else if(model == m_camera_names[3]) {
00094     // sony dsc-w30 photo camera, used to take the images for creating 3d models
00095     // it is used for testing purposes only
00096 
00097     // model images are undistorted
00098     const int w = 1632;
00099     const int h = 1224;
00100     const float cx = w/2.f;
00101     const float cy = h/2.f;
00102     const float f = 1790; // this depends on the image selected
00103 
00104     // the tester sends bw images
00105     //return CameraBridge(CameraBridge::BW, w, h, cx, cy, f, f);
00106     return CameraBridge(w, h, cx, cy, f, f);
00107 
00108   }else if(model == m_camera_names[4]) {
00109     // gazebo sim, custom parameters
00110 
00111     // model images are undistorted
00112     const int w = 640;
00113     const int h = 480;
00114     const float cx = 320.5f;
00115     const float cy = 240.5f;
00116     const float f = 320.f;
00117     //return CameraBridge(CameraBridge::BW, w, h, cx, cy, f, f);
00118     return CameraBridge(w, h, cx, cy, f, f);
00119 
00120   }else if(model == m_camera_names[5]) {
00121     // unibrain, but image is already rectified
00122     const float s = 2.f; // params are for 320x240, but images are at 640x480
00123                 const float cx = 171.78f * s; //171.95f * s;
00124                 const float cy = 127.41f  * s; //127.69f * s;
00125                 const float f = 196.8214f * s; //195.7243f * s;
00126                 const int w = 640;
00127                 const int h = 480;
00128 
00129                 return CameraBridge(w, h,
00130                         cx, cy, f, f, 0.f, 0.f, 0.f, 0.f);
00131 
00132   }else if(model == m_camera_names[6]) {
00133     // unibrain, but the bayer patter and the distortion must
00134     // be removed from the image
00135     // (this is a debugging camera)
00136    // Marta Parameters
00137         const float cx = 309.8205f; //171.95f * s;
00138                 const float cy = 252.1384f; //127.69f * s;
00139                 const float fx = 390.1922f; //195.7243f * s;
00140                 const float fy = 390.1463f;
00141         const float k1 = -0.3161f;
00142                 const float k2 = 0.0941f;
00143                 const int w = 640;
00144                 const int h = 480;
00145 /*
00146       const float s = 2.f; // params are for 320x240, but images are at 640x480
00147                 const float cx = 171.78f * s; //171.95f * s;
00148                 const float cy = 127.41f  * s; //127.69f * s;
00149                 const float f = 196.8214f * s; //195.7243f * s;
00150                 const float k1 = -0.3421f;
00151                 const float k2 = 0.1468f;
00152                 const int w = 640;
00153                 const int h = 480;
00154         */
00155                 return CameraBridge(CameraBridge::BAYER_BG, w, h,
00156                   cx, cy, fx, fy, k1, k2, 0.f, 0.f);
00157 
00158         }else if(model == m_camera_names[7]) {
00159     // Kinect
00160         const float cx = 313.4897f; //171.95f * s;
00161                 const float cy = 263.5015f; //127.69f * s;
00162                 const float fx = 526.6892f; //195.7243f * s;
00163                 const float fy = 526.9683f;
00164         const float k1 = 0.1370f;
00165                 const float k2 = -0.2156f;
00166                 const int w = 640;
00167                 const int h = 480;
00168 
00169                 return CameraBridge(CameraBridge::BAYER_BG, w, h,
00170                   cx, cy, fx, fy, k1, k2, 0.f, 0.f);
00171     }else{
00172                 throw std::string("Unknown camera");
00173         }
00174 
00175 }
00176 
00177 // ----------------------------------------------------------------------------
00178 
00179 bool CameraBridgeFactory::IsValid(const std::string& model)
00180 {
00181         if(model.empty()) return true;
00182 
00183         for(short i = 0; i < NCameras; ++i){
00184                 if(model == CameraBridgeFactory::m_camera_names[i]){
00185                         return true;
00186                 }
00187         }
00188         return false;
00189 }
00190 


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:49