Swissranger.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00023 
00024 #ifndef __IPA_SWISSRANGER_H__
00025 #define __IPA_SWISSRANGER_H__
00026 
00027 #include "StdAfx.h"
00028 
00029 // Windows
00030 #ifdef _WIN32
00031         // Windows with MinGW
00032         #ifdef __MINGW__
00033                 typedef short __wchar_t;
00034         #endif
00035 #endif
00036 
00037 // Linux
00038 #ifdef __LINUX__
00039 typedef unsigned long DWORD;
00040 #endif
00041 
00042 #ifdef __LINUX__
00043         #include <cob_camera_sensors/AbstractRangeImagingSensor.h>
00044 #else
00045         #include <cob_driver/cob_camera_sensors/common/include/cob_camera_sensors/AbstractRangeImagingSensor.h>
00046 #endif
00047 
00048 #include <stdio.h>
00049 #include <math.h>
00050 #include <sstream>
00051 #include <assert.h>
00052 #include <libMesaSR.h>
00053 
00054 namespace ipa_CameraSensors {
00055 
00056 // former SR31Consts.h entries
00057 #define SAFE_FREE(p)       { if(p) { delete (p); (p)=0; } }
00058 #define SWISSRANGER_COLUMNS 176
00059 #define SWISSRANGER_ROWS 144
00060 
00067 int LibMesaCallback(SRCAM srCam, unsigned int msg, unsigned int param, void* data);
00068 
00073 class __DLL_LIBCAMERASENSORS__ Swissranger : public AbstractRangeImagingSensor
00074 {
00075 public:
00076 
00077         Swissranger();
00078         ~Swissranger();
00079 
00080         //*******************************************************************************
00081         // AbstractRangeImagingSensor interface implementation
00082         //*******************************************************************************
00083 
00084         unsigned long Init(std::string directory, int cameraIndex = 0);
00085 
00086         unsigned long Open();
00087         unsigned long Close();
00088 
00089         unsigned long SetProperty(t_cameraProperty* cameraProperty);
00090         unsigned long SetPropertyDefaults();
00091         unsigned long GetProperty(t_cameraProperty* cameraProperty);
00092 
00093         unsigned long AcquireImages(int widthStepRange, int widthStepGray, int widthStepCartesian, char* RangeImage=NULL, char* IntensityImage=NULL,
00094                 char* cartesianImage=NULL, bool getLatestFrame=true, bool undistort=true,
00095                 ipa_CameraSensors::t_ToFGrayImageType grayImageType = ipa_CameraSensors::INTENSITY_32F1);
00096         unsigned long AcquireImages(cv::Mat* rangeImage = 0, cv::Mat* grayImage = 0,
00097                 cv::Mat* cartesianImage = 0, bool getLatestFrame = true, bool undistort = true,
00098                 ipa_CameraSensors::t_ToFGrayImageType grayImageType = ipa_CameraSensors::INTENSITY_32F1);
00099 
00100         unsigned long SaveParameters(const char* filename);
00101 
00102         bool isInitialized() {return m_initialized;}
00103         bool isOpen() {return m_open;}
00104 
00105 private:
00106         //*******************************************************************************
00107         // Camera specific members
00108         //*******************************************************************************
00109 
00110         unsigned long GetCalibratedZMatlab(int u, int v, float zRaw, float& zCalibrated);
00111         unsigned long GetCalibratedZSwissranger(int u, int v, int width, float& zCalibrated);
00112         unsigned long GetCalibratedXYMatlab(int u, int v, float z, float& x, float& y);
00113         unsigned long GetCalibratedXYSwissranger(int u, int v, int width, float& x, float& y);
00114 
00120         unsigned long LoadParameters(const char* filename, int cameraIndex);
00121 
00125         unsigned long SetParameters();
00126 
00127         SRCAM m_SRCam;                   
00128         int m_NumOfImages;               
00129         ImgEntry* m_DataBuffer;  
00130 
00131         // Stores for cartesian data, when native swissranger calibration is used
00132         float m_X[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00133         float m_Y[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00134         float m_Z[SWISSRANGER_COLUMNS * SWISSRANGER_ROWS];
00135 
00136         bool m_CoeffsInitialized; 
00137         bool m_GrayImageAcquireCalled; 
00138 
00143         cv::Mat m_CoeffsA0; 
00144         cv::Mat m_CoeffsA1; 
00145         cv::Mat m_CoeffsA2; 
00146         cv::Mat m_CoeffsA3; 
00147         cv::Mat m_CoeffsA4; 
00148         cv::Mat m_CoeffsA5; 
00149         cv::Mat m_CoeffsA6; 
00150 };
00151 
00154 __DLL_LIBCAMERASENSORS__ AbstractRangeImagingSensorPtr CreateRangeImagingSensor_Swissranger();
00155 
00156 } // End namespace ipa_CameraSensors
00157 #endif // __IPA_SWISSRANGER_H__
00158 
00159 


cob_camera_sensors
Author(s): Jan Fischer , Richard Bormann
autogenerated on Sat Jun 8 2019 21:02:02