Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00060
00061 #ifndef __IPA_SWISSRANGER_H__
00062 #define __IPA_SWISSRANGER_H__
00063
00064 #include "StdAfx.h"
00065
00066
00067 #ifdef _WIN32
00068
00069 #ifdef __MINGW__
00070 typedef short __wchar_t;
00071 #endif
00072 #endif
00073
00074
00075 #ifdef __LINUX__
00076 typedef unsigned long DWORD;
00077 #endif
00078
00079 #ifdef __LINUX__
00080 #include <cob_camera_sensors/AbstractRangeImagingSensor.h>
00081 #else
00082 #include <cob_driver/cob_camera_sensors/common/include/cob_camera_sensors/AbstractRangeImagingSensor.h>
00083 #endif
00084
00085 #include <stdio.h>
00086 #include <math.h>
00087 #include <sstream>
00088 #include <assert.h>
00089 #include <libMesaSR.h>
00090
00091 namespace ipa_CameraSensors {
00092
00093
00094 #define SAFE_FREE(p) { if(p) { delete (p); (p)=0; } }
00095 #define SWISSRANGER_COLUMNS 176
00096 #define SWISSRANGER_ROWS 144
00097
00104 int LibMesaCallback(SRCAM srCam, unsigned int msg, unsigned int param, void* data);
00105
00110 class __DLL_LIBCAMERASENSORS__ Swissranger : public AbstractRangeImagingSensor
00111 {
00112 public:
00113
00114 Swissranger();
00115 ~Swissranger();
00116
00117
00118
00119
00120
00121 unsigned long Init(std::string directory, int cameraIndex = 0);
00122
00123 unsigned long Open();
00124 unsigned long Close();
00125
00126 unsigned long SetProperty(t_cameraProperty* cameraProperty);
00127 unsigned long SetPropertyDefaults();
00128 unsigned long GetProperty(t_cameraProperty* cameraProperty);
00129
00130 unsigned long AcquireImages(int widthStepRange, int widthStepGray, int widthStepCartesian, char* RangeImage=NULL, char* IntensityImage=NULL,
00131 char* cartesianImage=NULL, bool getLatestFrame=true, bool undistort=true,
00132 ipa_CameraSensors::t_ToFGrayImageType grayImageType = ipa_CameraSensors::INTENSITY_32F1);
00133 unsigned long AcquireImages(cv::Mat* rangeImage = 0, cv::Mat* grayImage = 0,
00134 cv::Mat* cartesianImage = 0, bool getLatestFrame = true, bool undistort = true,
00135 ipa_CameraSensors::t_ToFGrayImageType grayImageType = ipa_CameraSensors::INTENSITY_32F1);
00136
00137 unsigned long SaveParameters(const char* filename);
00138
00139 bool isInitialized() {return m_initialized;}
00140 bool isOpen() {return m_open;}
00141
00142 private:
00143
00144
00145
00146
00147 unsigned long GetCalibratedZMatlab(int u, int v, float zRaw, float& zCalibrated);
00148 unsigned long GetCalibratedZSwissranger(int u, int v, int width, float& zCalibrated);
00149 unsigned long GetCalibratedXYMatlab(int u, int v, float z, float& x, float& y);
00150 unsigned long GetCalibratedXYSwissranger(int u, int v, int width, float& x, float& y);
00151
00157 unsigned long LoadParameters(const char* filename, int cameraIndex);
00158
00162 unsigned long SetParameters();
00163
00164 SRCAM m_SRCam;
00165 int m_NumOfImages;
00166 ImgEntry* m_DataBuffer;
00167
00168
00169 float m_X[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00170 float m_Y[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00171 float m_Z[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00172
00173 bool m_CoeffsInitialized;
00174 bool m_GrayImageAcquireCalled;
00175
00180 cv::Mat m_CoeffsA0;
00181 cv::Mat m_CoeffsA1;
00182 cv::Mat m_CoeffsA2;
00183 cv::Mat m_CoeffsA3;
00184 cv::Mat m_CoeffsA4;
00185 cv::Mat m_CoeffsA5;
00186 cv::Mat m_CoeffsA6;
00187 };
00188
00191 __DLL_LIBCAMERASENSORS__ AbstractRangeImagingSensorPtr CreateRangeImagingSensor_Swissranger();
00192
00193 }
00194 #endif // __IPA_SWISSRANGER_H__
00195
00196