Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
trv_dataProvider.hpp
00001 #ifndef TRV_DATAPROVIDER_HPP
00002 #define TRV_DATAPROVIDER_HPP
00003 
00004 #include "kernel/jafarException.hpp"
00005 
00006 #include "traversability/trv_util.hpp"
00007 
00008 #include "datareader/PositionReader.hpp"
00009 #include "datareader/ImageReader.hpp"
00010 
00011 #include "geom/t3d.hpp"
00012 #include "geom/t3dEuler.hpp"
00013 
00014 #include <image/Image.hpp>
00015 #include <string>
00016 #include <fstream>          // to read data files
00017 
00018 using namespace std;
00019 
00020 namespace jafar {
00021   namespace traversability {
00022     
00031     class DataProvider {
00032       
00033       private:
00034         FileInfoDataSet mFileInfo;
00035         jafar::datareader::PositionReader* mPosReader;
00036         jafar::datareader::ImageReader* mImgReader;
00037         std::string mExcepStr;
00038       
00039       public:
00044         DataProvider ( void );
00050         DataProvider ( FileInfoDataSet fileInfo );
00060         DataProvider ( std::string pathConfigFile, std::string excepStr = "none" );
00061         ~DataProvider ( void );
00062         
00069         void setup  ( std::string pathConfigFile, std::string excepStr = "none" );
00075         void setup  ( FileInfoDataSet fileInfo );
00082         void getPose ( int idx, CameraPoseParameters &camPose );
00089         CameraPoseParameters getPose ( int idx );
00096         void getImage ( int idx, jafar::image::Image &img );
00103         jafar::image::Image getImage ( int idx );
00110         void getData ( int idx, CameraPoseParameters &camPose, jafar::image::Image &img );
00114         void printFileInfo ( void );
00118         void printPoseData ( int idx );
00119         
00126         FileInfoDataSet parseConfigFile( std::string pathConfigFile );
00132         ImageInfo parseConfigFileForImageInfo ( std::string pathConfigFile );
00139         CameraIntrinsicParameters parseConfigFileForInternals ( std::string pathConfigFile );
00140         
00141       private:
00146         void initPositionReader ( FileInfoDataSet fileInfo );
00151         void initImageReader ( FileInfoDataSet fileInfo );
00152         jblas::vec6 getPoseDataFromSource ( jafar::datareader::PositionReader* posReader, int idx );
00153         CameraPoseParameters getPoseDataFromSourceStr ( jafar::datareader::PositionReader* posReader, int idx );
00161         template <typename T> T parseFile ( std::string pathConfigFile, std::string key )
00162         {
00163           // open config file
00164           ifstream inputFile;
00165           inputFile.open(pathConfigFile.c_str());
00166           T output = T(); 
00167           string str;
00168       
00169           while ( inputFile >> str )
00170           {
00171             if ( str == key )
00172             {
00173               inputFile >> output;
00174               break;
00175             }
00176           }
00177       
00178           // close config file
00179           inputFile.close();
00180       
00181           return output;
00182         }
00183     };
00184     
00185   } // traversability
00186 } // jafar
00187 
00188 
00189 
00190 
00191 
00192 #endif
00193 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:29 for Jafar by doxygen 1.7.6.1
LAAS-CNRS