Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CameraData.h

Go to the documentation of this file.
00001 #ifndef _CAMERADATA_H_
00002 #define _CAMERADATA_H_
00003 
00004 #include "Shared/RobotInfo.h"
00005 #include "Shared/plist.h"
00006 #include "Shared/Config.h"
00007 
00008 #include <iostream>
00009 using namespace std;
00010 
00011 struct CameraData : public plist::Dictionary {
00012   //! The camera alignment homography matrix
00013   plist::ArrayOf<plist::ArrayOf<plist::Primitive<float> > > homography;
00014   
00015   CameraData() : plist::Dictionary(false), homography(3, plist::ArrayOf<plist::Primitive<float> >(3, 0)) {
00016     addEntry("homography", homography, "Fill this with the approopriate homography matrix for camera alignment. You should probably\n"
00017          " use the calibrator unless you really know what you're doing");
00018     
00019     for(unsigned i = 0; i < 3; i++)
00020       for(unsigned j = 0; j < 3; j++)
00021         homography[i][j] = 0;
00022     homography [0][0] = homography[1][1] = homography[2][2] = 1;
00023   }
00024   
00025   void loadCameraData() {
00026     std::string path = config->getFileSystemRoot() + "/config/"+CameraName+".xml";
00027     
00028     int ret = plist::Dictionary::loadFile(path.c_str());
00029     if(ret == 0) {
00030       cout<<"--- Unable to load homography for \""<<path<<"\""<<endl;
00031       return;
00032     }
00033     for(unsigned i = 0; i < 3; i++)
00034       for(unsigned j = 0; j < 3; j++)
00035         CameraHomography(i,j) = homography[i][j];
00036   }
00037   
00038   void saveCameraData() {
00039     for(unsigned i = 0; i < 3; i++)
00040       for(unsigned j = 0; j < 3; j++)
00041         homography[i][j] = CameraHomography(i,j);
00042     
00043     std::string path = config->getFileSystemRoot() + "/config/"+CameraName+".xml";
00044     int ret = plist::Dictionary::saveFile(path.c_str());
00045     if(ret == 0)
00046       cout<<"--- Unable to save homography in \""<<path<<"\""<<endl;
00047   }
00048 };
00049 
00050 extern CameraData* cameraData;
00051 
00052 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:36 2016 by Doxygen 1.6.3