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 #ifndef _Aruco_board_h
00029 #define _Aruco_board_h
00030 #include <opencv2/core/core.hpp>
00031 #include <string>
00032 #include <vector>
00033 #include "exports.h"
00034 #include "marker.h"
00035 using namespace std;
00036 namespace aruco {
00040 struct ARUCO_EXPORTS MarkerInfo:public vector<cv::Point3f> {
00041     MarkerInfo() {}
00042     MarkerInfo(int _id) {id=_id; }
00043     MarkerInfo(const MarkerInfo&MI): vector<cv::Point3f>(MI){id=MI.id; }
00044     MarkerInfo & operator=(const MarkerInfo&MI){
00045         vector<cv::Point3f> ::operator=(MI);
00046         id=MI.id;
00047         return *this;
00048       }
00049     int id;
00050 };
00051 
00069 class ARUCO_EXPORTS  BoardConfiguration: public vector<MarkerInfo>
00070 {
00071     friend class Board;
00072 public:
00073     enum MarkerInfoType {NONE=-1,PIX=0,METERS=1};
00074     
00075     int mInfoType;
00078     BoardConfiguration();
00082     BoardConfiguration(string filePath)throw (cv::Exception);
00083 
00086     BoardConfiguration(const BoardConfiguration  &T);
00087 
00090     BoardConfiguration & operator=(const BoardConfiguration  &T);
00093     void saveToFile(string sfile)throw (cv::Exception);
00096     void readFromFile(string sfile)throw (cv::Exception);
00099     bool isExpressedInMeters()const {
00100         return mInfoType==METERS;
00101     }
00104     bool isExpressedInPixels()const {
00105         return mInfoType==PIX;
00106     }
00109     int getIndexOfMarkerId(int id)const;
00112     const MarkerInfo& getMarkerInfo(int id)const throw (cv::Exception);
00115     void getIdList(vector<int> &ids,bool append=true)const;
00116 private:
00119     void saveToFile(cv::FileStorage &fs)throw (cv::Exception);
00122     void readFromFile(cv::FileStorage &fs)throw (cv::Exception);
00123 };
00124 
00127 class ARUCO_EXPORTS Board:public vector<Marker>
00128 {
00129 
00130 public:
00131     BoardConfiguration conf;
00132     
00133     cv::Mat Rvec,Tvec;
00136     Board()
00137     {
00138         Rvec.create(3,1,CV_32FC1);
00139         Tvec.create(3,1,CV_32FC1);
00140         for (int i=0;i<3;i++)
00141             Tvec.at<float>(i,0)=Rvec.at<float>(i,0)=-999999;
00142     }
00143 
00147     void glGetModelViewMatrix(double modelview_matrix[16])throw(cv::Exception);
00148 
00159     void OgreGetPoseParameters(  double position[3], double orientation[4] )throw(cv::Exception);
00160 
00161 
00164     void saveToFile(string filePath)throw(cv::Exception);
00167     void readFromFile(string filePath)throw(cv::Exception);
00168 
00171     void draw(cv::Mat &im,cv::Scalar color, int lineWidth=1,bool writeId=true);
00172 };
00173 }
00174 
00175 #endif