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
00065 #ifdef _WIN32
00066
00067 #ifdef __MINGW__
00068 typedef short __wchar_t;
00069 #endif
00070 #endif
00071
00072
00073 #ifdef __LINUX__
00074 typedef unsigned long DWORD;
00075 #endif
00076
00077 #ifdef __COB_ROS__
00078 #include <cob_camera_sensors/AbstractRangeImagingSensor.h>
00079 #else
00080 #include <cob_driver/cob_camera_sensors/common/include/cob_camera_sensors/AbstractRangeImagingSensor.h>
00081 #endif
00082
00083 #include <stdio.h>
00084 #include <math.h>
00085 #include <sstream>
00086 #include <assert.h>
00087 #include <libMesaSR.h>
00088
00089 #ifdef SWIG
00090 %module Sensors3D
00091
00092 %{
00093 #include "Swissranger.h"
00094 %}
00095 #endif
00096
00097
00098 using namespace ipa_Utils;
00099
00100 namespace ipa_CameraSensors {
00101
00102
00103 #define SAFE_FREE(p) { if(p) { delete (p); (p)=0; } }
00104 #define SWISSRANGER_COLUMNS 176
00105 #define SWISSRANGER_ROWS 144
00106
00113 int LibMesaCallback(SRCAM srCam, unsigned int msg, unsigned int param, void* data);
00114
00119 class __DLL_LIBCAMERASENSORS__ Swissranger : public AbstractRangeImagingSensor
00120 {
00121 public:
00122
00123 Swissranger();
00124 ~Swissranger();
00125
00126
00127
00128
00129
00130 unsigned long Init(std::string directory, int cameraIndex = 0);
00131
00132 unsigned long Open();
00133 unsigned long Close();
00134
00135 unsigned long SetProperty(t_cameraProperty* cameraProperty);
00136 unsigned long SetPropertyDefaults();
00137 unsigned long GetProperty(t_cameraProperty* cameraProperty);
00138
00139 unsigned long AcquireImages(int widthStepRange, int widthStepGray, int widthStepCartesian, char* RangeImage=NULL, char* IntensityImage=NULL,
00140 char* cartesianImage=NULL, bool getLatestFrame=true, bool undistort=true,
00141 ipa_CameraSensors::t_ToFGrayImageType grayImageType = ipa_CameraSensors::INTENSITY_32F1);
00142 unsigned long AcquireImages(cv::Mat* rangeImage = 0, cv::Mat* grayImage = 0,
00143 cv::Mat* cartesianImage = 0, bool getLatestFrame = true, bool undistort = true,
00144 ipa_CameraSensors::t_ToFGrayImageType grayImageType = ipa_CameraSensors::INTENSITY_32F1);
00145
00146 unsigned long SaveParameters(const char* filename);
00147
00148 bool isInitialized() {return m_initialized;}
00149 bool isOpen() {return m_open;}
00150
00151 private:
00152
00153
00154
00155
00156 unsigned long GetCalibratedZMatlab(int u, int v, float zRaw, float& zCalibrated);
00157 unsigned long GetCalibratedZSwissranger(int u, int v, int width, float& zCalibrated);
00158 unsigned long GetCalibratedXYMatlab(int u, int v, float z, float& x, float& y);
00159 unsigned long GetCalibratedXYSwissranger(int u, int v, int width, float& x, float& y);
00160
00166 unsigned long LoadParameters(const char* filename, int cameraIndex);
00167
00171 unsigned long SetParameters();
00172
00173 SRCAM m_SRCam;
00174 int m_NumOfImages;
00175 ImgEntry* m_DataBuffer;
00176
00177
00178 float m_X[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00179 float m_Y[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00180 float m_Z[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00181
00182 bool m_CoeffsInitialized;
00183 bool m_GrayImageAcquireCalled;
00184
00189 cv::Mat m_CoeffsA0;
00190 cv::Mat m_CoeffsA1;
00191 cv::Mat m_CoeffsA2;
00192 cv::Mat m_CoeffsA3;
00193 cv::Mat m_CoeffsA4;
00194 cv::Mat m_CoeffsA5;
00195 cv::Mat m_CoeffsA6;
00196 };
00197
00200 __DLL_LIBCAMERASENSORS__ AbstractRangeImagingSensorPtr CreateRangeImagingSensor_Swissranger();
00201
00202 }
00203 #endif // __IPA_SWISSRANGER_H__
00204
00205