artoolkitplus.h

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 ARTOOKITPLUS_H
00021 #define ARTOOKITPLUS_H
00022 
00023 #include <ardev/ardevconfig.h>
00024 #ifdef HAVE_ARTOOLKITPLUS
00025 
00026 #include <ARToolKitPlus/ar.h>
00027 #include <ARToolKitPlus/Logger.h>
00028 #include <ardev/ardev.h>
00029 
00030 #include <map>
00031 
00032 namespace ARToolKitPlus
00033 {
00034         class Camera;
00035         class TrackerSingleMarker;
00036 }
00037 
00038 struct intlt
00039 {
00040         public: bool operator () (const int & lhs, const int &rhs)
00041         {
00042                 return lhs < rhs;
00043         };
00044 };
00045 
00046 class MyLogger : public ARToolKitPlus::Logger
00047 {
00048     void artLog(const char* nStr)
00049     {
00050         printf(nStr);
00051     }
00052 };
00053 
00054 
00058 class ARToolKitPlusPreProcess : public FrameProcessObject
00059 {
00060         public:
00062                 ARToolKitPlusPreProcess(CameraObject & Camera);
00063         
00065                 void ProcessFrame(const ARImage & frame);
00066                 
00069                 int AddPattern(int id, double Height=0);
00071                 void RemovePattern(int id);
00072 
00074                 bool GetMarkerPos(int id, ARPosition &result);
00075         
00076         private:
00077                 ARToolKitPlus::Camera * DummyCam;
00078                 unsigned int lastFrameWidth;            //< last width of a frame, used to scale calibration data
00079                 unsigned int lastFrameHeight;           //< last height of a frame, used to scale calibration data
00080                 int minfocnt;                           //< number of minfo structures returned last time
00081                 ARToolKitPlus::ARMarkerInfo *tmp_markers;               //< the information about the found markers
00082                 ARCamera camera;                                //< the camera
00083 
00084                 bool            useBCH;
00085                 MyLogger      logger;
00086                 ARToolKitPlus::TrackerSingleMarker *tracker;
00087                 ARImage GrayImage;
00088                 
00089                 std::map<int,double,intlt> MarkerHeights; //< A map of the marker Heights
00090 
00091 };
00092 
00095 class ARToolKitPlusPosition : public PositionObject
00096 {
00097         public:
00099                 ARToolKitPlusPosition(ARToolKitPlusPreProcess & pre,int ID,double Height) : Pre(pre) 
00100                 {
00101                         DroppedFrames = 0;
00102                         MarkerID = Pre.AddPattern(ID, Height);
00103                 }; 
00105                 ~ARToolKitPlusPosition()
00106                 {
00107                         Pre.RemovePattern(MarkerID);
00108                 }; 
00109         
00111                 virtual ARPosition GetPosition();
00112 
00114                 virtual bool Present();
00115         
00116         protected:
00117                 ARToolKitPlusPreProcess & Pre;
00118                 unsigned int MarkerID;
00119                 ARPosition lastGoodPosition;
00120                 int DroppedFrames;
00121 };
00122 
00123 #endif
00124 #endif

SourceForge.net Logo Generated on Sat May 12 15:25:43 2007 for ardev by doxygen 1.5.1