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
00058
00059 #ifndef __IPA_VIRTUALRANGECAM_H__
00060 #define __IPA_VIRTUALRANGECAM_H__
00061
00062 #include "StdAfx.h"
00063
00064 #ifdef __LINUX__
00065 #include <cob_camera_sensors/AbstractRangeImagingSensor.h>
00066 #else
00067 #include <cob_driver/cob_camera_sensors/common/include/cob_camera_sensors/AbstractRangeImagingSensor.h>
00068 #endif
00069
00070 #include <stdio.h>
00071 #include <math.h>
00072 #include <assert.h>
00073 #include <sstream>
00074
00075 #include <boost/filesystem.hpp>
00076
00077 namespace ipa_CameraSensors {
00078
00079 static const int SWISSRANGER_COLUMNS = 176;
00080 static const int SWISSRANGER_ROWS = 144;
00081
00086 class __DLL_LIBCAMERASENSORS__ VirtualRangeCam : public AbstractRangeImagingSensor
00087 {
00088 public:
00089
00090 VirtualRangeCam();
00091 ~VirtualRangeCam();
00092
00093
00094
00095
00096
00097 unsigned long Init(std::string directory, int cameraIndex = 0);
00098
00099 unsigned long Open();
00100 unsigned long Close();
00101
00102 unsigned long SetProperty(t_cameraProperty* cameraProperty);
00103 unsigned long SetPropertyDefaults();
00104 unsigned long GetProperty(t_cameraProperty* cameraProperty);
00105
00106 unsigned long AcquireImages(int widthStepRange, int widthStepGray, int widthStepCartesian, char* rangeImage=NULL, char* intensityImage=NULL,
00107 char* cartesianImage=NULL, bool getLatestFrame=true, bool undistort=true,
00108 ipa_CameraSensors::t_ToFGrayImageType grayImageType = ipa_CameraSensors::INTENSITY_32F1);
00109 unsigned long AcquireImages(cv::Mat* rangeImage = 0, cv::Mat* intensityImage = 0,
00110 cv::Mat* cartesianImage = 0, bool getLatestFrame = true, bool undistort = true,
00111 ipa_CameraSensors::t_ToFGrayImageType grayImageType = ipa_CameraSensors::INTENSITY_32F1);
00112
00113 unsigned long GetCalibratedUV(double x, double y, double z, double& u, double& v);
00114
00115 unsigned long SaveParameters(const char* filename);
00116
00117 bool isInitialized() {return m_initialized;}
00118 bool isOpen() {return m_open;}
00119
00122 int GetNumberOfImages();
00123
00128 unsigned long SetPathToImages(std::string path);
00129
00130 private:
00131
00132
00133
00134
00137 inline void UpdateImageDimensionsOnFirstImage(std::string filename, std::string ext=".xml");
00138
00143 inline void FindSourceImageFormat(std::map<std::string, int>::iterator& itCounter, std::string& ext);
00144
00145 unsigned long GetCalibratedZMatlab(int u, int v, float zRaw, float& zCalibrated);
00146 unsigned long GetCalibratedXYMatlab(int u, int v, float z, float& x, float& y);
00147
00153 unsigned long LoadParameters(const char* filename, int cameraIndex);
00154
00155 bool m_CoeffsInitialized;
00156
00161 cv::Mat m_CoeffsA0;
00162 cv::Mat m_CoeffsA1;
00163 cv::Mat m_CoeffsA2;
00164 cv::Mat m_CoeffsA3;
00165 cv::Mat m_CoeffsA4;
00166 cv::Mat m_CoeffsA5;
00167 cv::Mat m_CoeffsA6;
00168
00169 std::string m_CameraDataDirectory;
00170 int m_CameraIndex;
00171
00172 std::vector<std::string> m_AmplitudeImageFileNames;
00173 std::vector<std::string> m_IntensityImageFileNames;
00174 std::vector<std::string> m_RangeImageFileNames ;
00175 std::vector<std::string> m_CoordinateImageFileNames ;
00176
00177 int m_ImageWidth;
00178 int m_ImageHeight;
00179
00180 double m_k1, m_k2, m_p1, m_p2;
00181 };
00182
00185 __DLL_LIBCAMERASENSORS__ AbstractRangeImagingSensorPtr CreateRangeImagingSensor_VirtualCam();
00186
00187 }
00188 #endif // __IPA_VIRTUALRANGECAM_H__
00189
00190