00001 /* -- 2007-05-07 -- 00002 * ardev - an augmented reality library for robot developers 00003 * Copyright 2005-2007 - Toby Collett (ardev _at_ plan9.net.nz) 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 */ 00020 #ifndef ARTOOKIT_H 00021 #define ARTOOKIT_H 00022 00023 #include <ardev/ardev.h> 00024 #include <AR/ar.h> 00025 00026 #include <map> 00027 00028 struct intlt 00029 { 00030 public: bool operator () (const int & lhs, const int &rhs) 00031 { 00032 return lhs < rhs; 00033 }; 00034 }; 00035 00039 class ARToolKitPreProcess : public FrameProcessObject 00040 { 00041 public: 00043 ARToolKitPreProcess(/*const char * CameraFile,*/ const int Threshold, CameraObject & Camera); 00044 00046 void ProcessFrame(const ARImage & frame); 00047 00050 int AddPattern(const char *filename, double Height=0); 00052 void RemovePattern(int id); 00053 00055 bool GetMarkerPos(int id, ARPosition &result); 00056 00057 private: 00058 ARParam unscaledCamParam; //< unscaled camera calibration data from config file given to constructor 00059 unsigned int lastFrameWidth; //< last width of a frame, used to scale calibration data 00060 unsigned int lastFrameHeight; //< last height of a frame, used to scale calibration data 00061 int minfocnt; //< number of minfo structures returned last time 00062 ARMarkerInfo *minfo; //< the information about the found markers 00063 int threshold; //< the threshold to use with the arDetect function 00064 ARCamera camera; //< the camera 00065 00066 std::map<int,double,intlt> MarkerHeights; //< A map of the marker Heights 00067 00068 }; 00069 00072 class ARToolKitPosition : public PositionObject 00073 { 00074 public: 00076 ARToolKitPosition(ARToolKitPreProcess & pre,const char * PatFile, double Height) : Pre(pre) 00077 { 00078 MarkerID = Pre.AddPattern(PatFile, Height); 00079 }; 00081 ~ARToolKitPosition() 00082 { 00083 Pre.RemovePattern(MarkerID); 00084 }; 00085 00087 virtual ARPosition GetPosition(); 00088 00089 protected: 00090 ARToolKitPreProcess & Pre; 00091 unsigned int MarkerID; 00092 ARPosition lastGoodPosition; 00093 }; 00094 00095 #endif