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
00052 return CameraBridge();
00053
00054
00055 }else if(model == m_camera_names[0]){
00056
00057 return CameraBridge();
00058
00059
00060 }else if(model == m_camera_names[1]){
00061
00062 const float s = 2.f;
00063 const float cx = 171.78f * s;
00064 const float cy = 127.41f * s;
00065 const float f = 196.8214f * 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
00072
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]){
00077
00078
00079 const float s = 1.f;
00080 const float cx = 171.78f * s;
00081 const float cy = 127.41f * s;
00082 const float f = 196.8214f * 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
00089
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
00095
00096
00097
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;
00103
00104
00105
00106 return CameraBridge(w, h, cx, cy, f, f);
00107
00108 }else if(model == m_camera_names[4]) {
00109
00110
00111
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
00118 return CameraBridge(w, h, cx, cy, f, f);
00119
00120 }else if(model == m_camera_names[5]) {
00121
00122 const float s = 2.f;
00123 const float cx = 171.78f * s;
00124 const float cy = 127.41f * s;
00125 const float f = 196.8214f * 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
00134
00135
00136
00137 const float cx = 309.8205f;
00138 const float cy = 252.1384f;
00139 const float fx = 390.1922f;
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
00147
00148
00149
00150
00151
00152
00153
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
00160 const float cx = 313.4897f;
00161 const float cy = 263.5015f;
00162 const float fx = 526.6892f;
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