File osgART-1.0-ARToolKitPlus-tracker.patch of Package osgART

Index: osgART-1.0/bin/osgART.bkl
===================================================================
--- osgART-1.0.orig/bin/osgART.bkl
+++ osgART-1.0/bin/osgART.bkl
@@ -69,6 +69,18 @@
 		
 	</module>
 
+	<module id="osgart_artoolkitplus_tracker" template="simple">
+		<cxx-rtti>on</cxx-rtti>
+		<sources>$(addPrefixToList('../src/osgART/Tracker/ARToolKitPlus/','ARToolKitPlusTracker.cpp MultiMarker.cpp SingleMarker.cpp SimpleMarker.cpp Main.cpp gsub.cpp'))</sources>
+
+		<include>../include</include>
+		<include>.</include>
+
+		<library>osgART</library>
+
+		<sys-lib>osg</sys-lib>
+		<sys-lib>ARToolKitPlus</sys-lib>
+        </module>
 
 	<module id="osgart_dummyimage">
 		<cxx-rtti>on</cxx-rtti>
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/ARToolKitPlusTracker
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/ARToolKitPlusTracker
@@ -0,0 +1,205 @@
+/*
+ *	osgART/Tracker/ARToolKit/ARToolKitPlusTracker
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#ifndef OSGART_ARTTOOLKITTRACKER
+#define OSGART_ARTTOOLKITTRACKER
+
+/**
+ * \file  ARToolKitPlusTracker
+ * \brief A wrapper class for ARToolkit tracking system.
+ *
+ * Support Marker-Based tracking based on computer vision based on ARToolKit
+ * Algorithm. This class provided video/graphic independent marker detection and
+ * support multiple marker tracking.
+ *	
+ * \author Philip Lamb philip.lamb@artoolworks.com
+ * \author Julian Looser Julian.Looser@hitlabnz.org
+ * \author Raphael Grasset Raphael.Grasset@hitlabnz.org
+ */
+
+#include "osgART/Export"
+#include "osgART/Marker"
+#include "osgART/GenericVideo"
+#include "osgART/GenericTracker"
+
+#include <string>
+
+#include <ARToolKitPlus/TrackerMultiMarker.h>
+
+
+namespace osgART {
+
+	/**
+	* \class ARToolKitPlusTracker
+	* \brief A tracker based on ARToolKit 2x. 
+	* 
+	* This tracker supports single and multi-markers.
+	*
+	*/
+	class ARToolKitPlusTracker : public GenericTracker
+	{
+
+	public:        
+	   
+		/** 
+		* \brief constructor.
+		*/
+		ARToolKitPlusTracker(void);
+
+		/** 
+		* \brief set the openGL parameters for the projection matrix.
+		* 
+		* Initialize internal parameters computation for delivers an openGL Matrix (modify
+		* nothing to openGL state machine). 
+		* \param n near field of view
+		* \param f far field of view
+		*/
+		void setProjection(const double n, const double f);
+		
+		/** 
+		* \brief Set the threshold value for the tracking algorithm.
+		* 
+		* Define the threshold used to binarize the image in ARToolkit.
+		* \param thresh integer value between 0 (dark) and 255 (bright) 
+		*/
+		void setThreshold(const int& thresh);
+		
+		/**
+		* \brief Get the current threshold value for the tracking algorithm.
+		*
+		* \return The current threshold.
+		*/
+		int getThreshold() const;	
+		
+
+		unsigned char* getDebugImage();	
+		void setDebugMode(bool d);
+		bool getDebugMode();
+		
+		
+		/** 
+		* \brief Initialize ARToolKit.
+		* 
+		* This core function initializes different parameters of ARToolKit: load tracked markers, initialize
+		* camera parameters.
+		* \param xsize width of the image to analyze
+		* \param ysize height of the image to analyze
+		* \param pattlist_name a file structure of the marker
+		* \param camera_name description file of the camera used (pinhole model)
+		*/
+		virtual bool init(int xsize, int ysize, 
+			const std::string& pattlist_name = "Data/markers_list.dat", 
+			const std::string& camera_name="Data/camera_para.dat");
+		
+		/** 
+		* \brief Register a single marker with the tracker.
+		* 
+		* \param pattFile the pattern file name
+		* \param width the width of the physical marker
+		* \param center the x-y coordinates of the center of the marker (usually 0,0)
+		* \return the internal ID of the new marker, or -1 on failure 
+		*/
+		int addSingleMarker(const std::string& pattFile, 
+			double width, double center[2]);
+
+		int addSimpleMarker(const std::string& pattFile, 
+			double width, double center[2]);
+		
+		/** 
+		* \brief Register a multi-marker with the tracker
+		* 
+		* \param multiFile the multi-marker configuration file name
+		* \return the internal ID of the new marker, or -1 on failure
+		*/
+		int addMultiMarker(const std::string& multiFile);
+		
+		/** 
+		* \brief set the image which will be used for tracking.
+		* 
+		* \param image Pointer to raw image pixels.
+		* \param format OSGART-defined pixel format of the raw pixels. This will be converted
+		*		to a format understood by ARToolKit internally.
+		*/
+		virtual void setImageRaw(unsigned char * image, PixelFormatType format = VIDEOFORMAT_GREY8);
+		
+		/** 
+		* \brief update the tracking.
+		* 
+		* This core function applies the ARToolKit algorithm to the last image defined by setImage.
+		*/
+		void update();
+
+                virtual Marker* getMarker(int markerId);
+		
+	protected:
+	
+		/** 
+		 * \brief destructor.
+		 */
+		virtual ~ARToolKitPlusTracker();
+		
+		virtual void createUndistortedMesh(int,int,float,float,osg::Geometry&);
+				
+	private:
+		
+		struct				CameraParameter;
+		CameraParameter*	m_cparam;
+	
+		bool setupMarkers(const std::string& patternListFile);
+		void cleanupMarkers(void);
+
+		std::string 		cparamName;
+		int					m_threshold;
+
+		bool 				m_debugmode;
+		
+		int					m_marker_num;
+		
+                int                 m_artoolkit_pixformat;
+                int                 m_artoolkit_pixsize;
+
+                ARToolKitPlus::TrackerMultiMarker *m_tracker;
+
+	};
+
+
+
+
+};
+
+
+#endif 
+
+
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/ARToolKitPlusTracker.cpp
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/ARToolKitPlusTracker.cpp
@@ -0,0 +1,640 @@
+/*
+ *	osgART/Tracker/ARToolKit/ARToolKitPlusTracker
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#include "ARToolKitPlusTracker"
+
+/*
+#include <AR/config.h>
+#include <AR/video.h>
+#include <AR/ar.h>
+#include <AR/gsub_lite.h>
+#ifndef AR_HAVE_HEADER_VERSION_2_72
+#error ARToolKit v2.72 or later is required to build the OSGART ARToolKit tracker.
+#endif
+*/
+
+//#include <ARToolKitPlus/Tracker.h>
+
+#include "gsub.h"
+
+#include "SingleMarker"
+#include "MultiMarker"
+#include "SimpleMarker"
+
+#include <osgART/GenericVideo>
+#include <osg/Notify>
+
+#include <iostream>
+#include <fstream>
+
+#include <ARToolKitPlus/TrackerMultiMarker.h>
+
+#define PD_LOOP 3
+
+using namespace ARToolKitPlus;
+
+template <typename T> 
+int Observer2Ideal(	const T dist_factor[4], 
+					const T ox, 
+					const T oy,
+					T *ix, T *iy )
+{
+    T  z02, z0, p, q, z, px, py;
+    register int i = 0;
+
+    px = ox - dist_factor[0];
+    py = oy - dist_factor[1];
+    p = dist_factor[2]/100000000.0;
+    z02 = px*px+ py*py;
+    q = z0 = sqrt(px*px+ py*py);
+
+    for( i = 1; ; i++ ) {
+        if( z0 != 0.0 ) {
+            z = z0 - ((1.0 - p*z02)*z0 - q) / (1.0 - 3.0*p*z02);
+            px = px * z / z0;
+            py = py * z / z0;
+        }
+        else {
+            px = 0.0;
+            py = 0.0;
+            break;
+        }
+        if( i == PD_LOOP ) break;
+
+        z02 = px*px+ py*py;
+        z0 = sqrt(px*px+ py*py);
+    }
+
+    *ix = px / dist_factor[3] + dist_factor[0];
+    *iy = py / dist_factor[3] + dist_factor[1];
+
+    return(0);
+}
+
+
+namespace osgART {
+
+	struct ARToolKitPlusTracker::CameraParameter 
+	{
+		Camera cparam;
+	};
+
+
+	ARToolKitPlusTracker::ARToolKitPlusTracker() : GenericTracker(),
+		m_threshold(100),
+		m_debugmode(false),
+		m_marker_num(0),
+		m_cparam(new CameraParameter)
+	{		
+
+		// create a new field 
+		m_fields["threshold"] = new CallbackField<ARToolKitPlusTracker,int>(this,
+			&ARToolKitPlusTracker::getThreshold,
+			&ARToolKitPlusTracker::setThreshold);
+		
+		// attach a new field to the name "debug"
+		m_fields["debug"] = new TypedField<bool>(&m_debugmode);
+
+		// for statistics
+		m_fields["markercount"] = new TypedField<int>(&m_marker_num);
+	}
+
+	ARToolKitPlusTracker::~ARToolKitPlusTracker()
+	{
+		delete m_cparam;
+	}
+
+
+	bool ARToolKitPlusTracker::init(int xsize, int ysize, 
+		const std::string& pattlist_name, 
+		const std::string& camera_name)
+	{
+		Camera  wparam;
+		
+	    // Set the initial camera parameters.
+		cparamName = camera_name;
+	    //if(arParamLoad((char*)cparamName.c_str(), 2, &wparam) < 0) {
+
+               
+                m_tracker = new ARToolKitPlus::TrackerMultiMarker(xsize,ysize,9,6,6,6,9);
+
+                m_tracker->setMarkerMode(MARKER_ID_SIMPLE);
+                m_tracker->setBorderWidth(0.125);
+                //m_tracker->setMarkerMode(MARKER_TEMPLATE);
+                //m_tracker->setBorderWidth(0.25);
+
+
+                // these are all accuracy enhancements, you can comment them out to return to the defaults
+                m_tracker->activateAutoThreshold(true);
+                m_tracker->setNumAutoThresholdRetries(5);
+                m_tracker->setPoseEstimator(POSE_ESTIMATOR_RPP);
+                m_tracker->setImageProcessingMode(IMAGE_FULL_RES);
+
+
+
+	    //if(!m_tracker->loadCameraFile((char*)cparamName.c_str(),10.0f,8000.0f)) {
+            // we use this "high level" init function because it sets up some things that i can't access
+            // with the lower level functions (!!). we pass in an empty marker file because we want to add
+            // markers one by one and keep track of them.
+            
+                float near = 10.0f;
+                float far = 8000.0f;
+
+            if(!m_tracker->init((char*)cparamName.c_str(),"Data/empty.cfg",near,far)) {
+			
+			// 
+			osg::notify(osg::FATAL) 
+				<< "osgART::ARToolKitPlusTracker::init(video,patternlist,cameraparam) Can't load camera parameters from '"<<
+				camera_name <<"'." << std::endl;
+			
+			return false;
+	    }
+
+            //m_tracker->convertProjectionMatrixToOpenGLStyle(&(m_cparam->cparam), near, far, m_projectionMatrix);
+
+
+        // slightly less ugly hack
+        arglCameraFrustumRH(m_tracker->getCamera(), near, far, m_projectionMatrix);
+
+/*
+            printf("PROJECTION MATRIX:\n");
+            for(int i=0;i<16;i++) {
+                printf(" %f",m_projectionMatrix[i] = m_tracker->getProjectionMatrix()[i]);
+                if(i%4==3) printf("\n");
+            }
+            */
+
+	    //arParamChangeSize(&wparam, xsize, ysize,&(m_cparam->cparam));
+            //Tracker::changeCameraSize(xsize,ysize);
+	    //arInitCparam(&(m_cparam->cparam));
+	    //arParamDisp(&(m_cparam->cparam));
+
+		//arFittingMode = AR_FITTING_TO_IDEAL;
+	    //arImageProcMode = AR_IMAGE_PROC_IN_FULL;
+
+		//setProjection(10.0f, 8000.0f);
+		setDebugMode(m_debugmode);
+		setThreshold(m_threshold);
+
+		if (!setupMarkers(pattlist_name)) {
+			std::cerr << "ERROR: Marker setup failed." << std::endl;
+			return false;
+		}
+
+		// Success
+		return true;
+	}
+
+
+	std::string trim(std::string& s,const std::string& drop = " ")
+	{
+		std::string r=s.erase(s.find_last_not_of(drop)+1);
+		return r.erase(0,r.find_first_not_of(drop));
+	}
+
+
+	bool ARToolKitPlusTracker::setupMarkers(const std::string& patternListFile)
+	{
+		std::ifstream markerFile;
+
+		// Need to check whether the passed file even exists
+
+		markerFile.open(patternListFile.c_str());
+
+		// Need to check for error when opening file
+		if (!markerFile.is_open()) return false;
+
+		bool ret = true;
+
+		int patternNum = 0;
+		markerFile >> patternNum;
+
+		std::string patternName, patternType;
+
+		// Need EOF checking in here... atm it assumes there are really as many markers as the number says
+
+		for (int i = 0; (i < patternNum) && (!markerFile.eof()); i++)
+		{
+			// jcl64: Get the whole line for the marker file (will handle spaces in filename)
+			patternName = "";
+			while (trim(patternName) == "" && !markerFile.eof()) {
+				getline(markerFile, patternName);
+			}
+			
+			
+			// Check whether markerFile exists?
+
+			markerFile >> patternType;
+
+			if (patternType == "SINGLE")
+			{
+				
+				double width, center[2];
+				markerFile >> width >> center[0] >> center[1];
+				if (addSingleMarker(patternName, width, center) == -1) {
+					std::cerr << "Error adding single pattern: " << patternName << std::endl;
+					ret = false;
+					break;
+				}
+
+			}
+			else if (patternType == "MULTI")
+			{
+				if (addMultiMarker(patternName) == -1) {
+					std::cerr << "Error adding multi-marker pattern: " << patternName << std::endl;
+					ret = false;
+					break;
+				}
+
+			} 
+			else if (patternType == "SIMPLE")
+			{
+				double width, center[2];
+				markerFile >> width >> center[0] >> center[1];
+				if (addSimpleMarker(patternName,width,center) == -1) {
+					std::cerr << "Error adding simple-marker pattern: " << patternName << std::endl;
+					ret = false;
+					break;
+				}
+
+			} 
+			else 
+			{
+				std::cerr << "Unrecognized pattern type: " << patternType << std::endl;
+				ret = false;
+				break;
+			}
+		}
+
+		markerFile.close();
+
+		return ret;
+	}
+
+	int 
+	ARToolKitPlusTracker::addSingleMarker(const std::string& pattFile, double width, double center[2]) {
+
+		SingleMarker* singleMarker = new SingleMarker(m_tracker);
+
+		if (!singleMarker->initialise(pattFile, width, center))
+		{
+			singleMarker->unref();
+			return -1;
+		}
+
+		m_markerlist.push_back(singleMarker);
+
+		return m_markerlist.size() - 1;
+	}
+
+	int 
+	ARToolKitPlusTracker::addSimpleMarker(const std::string& pattFile, double width, double center[2]) {
+
+		SimpleMarker* simpleMarker = new SimpleMarker(m_tracker);
+
+		if (!simpleMarker->initialise(atoi(pattFile.c_str()), width, center))
+		{
+			simpleMarker->unref();
+			return -1;
+		}
+
+		m_markerlist.push_back(simpleMarker);
+
+		return m_markerlist.size() - 1;
+	}
+
+	int 
+	ARToolKitPlusTracker::addMultiMarker(const std::string& multiFile) 
+	{
+		MultiMarker* multiMarker = new MultiMarker(m_tracker);
+		
+		if (!multiMarker->initialise(multiFile))
+		{
+			multiMarker->unref();
+			return -1;
+		}
+
+		m_markerlist.push_back(multiMarker);
+
+		return m_markerlist.size() - 1;
+
+	}
+
+	void ARToolKitPlusTracker::setThreshold(const int& thresh)	
+	{
+		m_threshold = osg::clampBetween(thresh,0,255);		
+	}
+
+	int ARToolKitPlusTracker::getThreshold() const 
+	{
+		return m_threshold;
+	}
+
+	unsigned char* ARToolKitPlusTracker::getDebugImage() {
+		//return arImage;
+		return 0;
+	}
+		
+	void ARToolKitPlusTracker::setDebugMode(bool d) 
+	{
+		m_debugmode = d;
+		//arDebug = (m_debugmode) ? 1 : 0;
+	}
+
+	bool ARToolKitPlusTracker::getDebugMode() 
+	{
+		return m_debugmode;
+	}
+
+    /*virtual*/ 
+	void ARToolKitPlusTracker::setImageRaw(unsigned char * image, PixelFormatType format)
+    {
+		if (m_imageptr_format != format) {
+			// format has changed.
+			// Translate the pixel format to an appropriate type for ARToolKit v2.
+			switch (format) {
+				case VIDEOFORMAT_RGB24:
+					m_artoolkit_pixformat = PIXEL_FORMAT_RGB;
+					m_artoolkit_pixsize = 3;
+					break;
+				case VIDEOFORMAT_BGR24:
+					m_artoolkit_pixformat = PIXEL_FORMAT_BGR;
+					m_artoolkit_pixsize = 3;
+					break;
+				case VIDEOFORMAT_BGRA32:
+					m_artoolkit_pixformat = PIXEL_FORMAT_BGRA;
+					m_artoolkit_pixsize = 4;
+					break;
+				case VIDEOFORMAT_RGBA32:
+					m_artoolkit_pixformat = PIXEL_FORMAT_RGBA;
+					m_artoolkit_pixsize = 4;
+					break;
+                                /*
+				case VIDEOFORMAT_ARGB32:
+					m_artoolkit_pixformat = PIXEL_FORMAT_ARGB;
+					m_artoolkit_pixsize = 4;
+					break;
+                                */
+				case VIDEOFORMAT_ABGR32:
+					m_artoolkit_pixformat = PIXEL_FORMAT_ABGR;
+					m_artoolkit_pixsize = 4;
+					break;
+                                        /*
+                                case VIDEOFORMAT_YUV422:
+					m_artoolkit_pixformat = PIXEL_FORMAT_2vuy;
+					m_artoolkit_pixsize = 2;
+					break;
+                                        */
+				case VIDEOFORMAT_Y8:
+				case VIDEOFORMAT_GREY8:
+					m_artoolkit_pixformat = PIXEL_FORMAT_LUM;
+					m_artoolkit_pixsize = 1;
+					break;
+				default:
+					break;
+			}        
+		}
+		
+        // We are only augmenting method in parent class.
+        GenericTracker::setImageRaw(image, format);
+    }
+
+	void ARToolKitPlusTracker::update()
+	{
+
+		ARMarkerInfo    *marker_info;					// Pointer to array holding the details of detected markers.
+		
+		
+	    register int             j, k;
+
+		// Do not update with a null image
+		if (m_imageptr == NULL) return;
+
+#if 0
+        // Check that the format matches the one passed in.
+		if (AR_PIX_SIZE_DEFAULT != m_artoolkit_pixsize || AR_DEFAULT_PIXEL_FORMAT != m_artoolkit_pixformat) {
+			std::cerr << "osgart_artoolkit_tracker::update() Incompatible pixelformat!" << std::endl;
+			return;
+		}
+#endif
+
+		// Detect the markers in the video frame.
+		if(m_tracker->arDetectMarker(m_imageptr, m_threshold, &marker_info, &m_marker_num) < 0) 
+		{
+			std::cerr << "Error detecting markers in image." << std::endl;
+			return;
+		}
+
+                /*
+                int *detected_markers;
+                m_tracker->getDetectedMarkers(detected_markers);
+                osg::notify() << "detected ids: ";
+                for(j = 0; j < m_tracker->getNumDetectedMarkers() ; j++) {
+                  if(j>0)
+                      osg::notify() << ", ";
+                  osg::notify() << detected_markers[j];
+                }
+                osg::notify() << std::endl;
+                */
+
+
+                osg::notify() << "m_marker_num " << m_marker_num << std::endl;
+                /*
+                for (j = 0 ; j < m_marker_num ; j++ ) {
+
+                    osg::notify() << "index: " << j << std::endl;
+                    osg::notify() << "area: " << marker_info[j].area << std::endl;
+                    osg::notify() << "id: " << marker_info[j].id << std::endl;
+                    osg::notify() << "dir: " << marker_info[j].dir << std::endl;
+                    osg::notify() << "cf: " << marker_info[j].cf << std::endl;
+                    osg::notify() << "pos: " << marker_info[j].pos[0] << "," << marker_info[j].pos[1]  << std::endl;
+                }
+                */
+
+		MarkerList::iterator _end = m_markerlist.end();
+			
+		// Check through the marker_info array for highest confidence
+		// visible marker matching our preferred pattern.
+		for (MarkerList::iterator iter = m_markerlist.begin(); 
+			iter != _end; 
+			++iter)		
+		{
+
+			SingleMarker* singleMarker = dynamic_cast<SingleMarker*>((*iter).get());
+			SimpleMarker* simpleMarker = dynamic_cast<SimpleMarker*>((*iter).get());
+			MultiMarker* multiMarker = dynamic_cast<MultiMarker*>((*iter).get());
+
+			if (singleMarker)
+			{			
+
+				k = -1;
+				for (j = 0; j < m_marker_num; j++)	
+				{
+					if (singleMarker->getPatternID() == marker_info[j].id) 
+					{
+						if (k == -1) k = j; // First marker detected.
+						else 
+						if(marker_info[j].cf > marker_info[k].cf) k = j; // Higher confidence marker detected.
+
+					}
+				}
+					
+				if(k != -1) 
+				{
+					singleMarker->update(&marker_info[k]); 
+				} 
+				else 
+				{
+					singleMarker->update(NULL);
+				}
+			}
+                        else if (simpleMarker)
+			{			
+                                    //osg::notify() << "testing simpleMarker, name: " << simpleMarker->getName() << std::endl;
+
+				k = -1;
+				for (j = 0; j < m_marker_num; j++)	
+				{
+                                    //osg::notify() << "testing detected marker, id: " << marker_info[j].id << std::endl;
+
+					if (simpleMarker->getPatternID() == marker_info[j].id) 
+					{
+                                            //osg::notify() << "matched marker, name: " << simpleMarker->getName() << ", id=" << marker_info[j].id << std::endl;
+						if (k == -1) k = j; // First marker detected.
+						else 
+						if(marker_info[j].cf > marker_info[k].cf) k = j; // Higher confidence marker detected.
+
+					}
+				}
+					
+				if(k != -1) 
+				{
+					simpleMarker->update(&marker_info[k]); 
+				} 
+				else 
+				{
+					simpleMarker->update(NULL);
+				}
+                                osg::Vec3d trans = simpleMarker->getTransform().getTrans();
+                                //printf("simple marker %s transform: %f %f %f %s\n",simpleMarker->getName().c_str(),trans.x(),trans.y(),trans.z(),simpleMarker->isValid()?"valid":"invalid");
+			}
+			else if (multiMarker)
+			{
+				multiMarker->update(marker_info, m_marker_num);
+				
+			} else {
+				std::cerr << "ARToolKitPlusTracker::update() : Unknown marker type id!" << std::endl;
+			}
+		}
+// #endif
+
+	}
+
+	void ARToolKitPlusTracker::setProjection(const double n, const double f) 
+	{
+            m_tracker->setCamera(m_tracker->getCamera(),n,f);
+
+        arglCameraFrustumRH(m_tracker->getCamera(), n, f, m_projectionMatrix);
+            //convertProjectionMatrixToOpenGLStyle(&(m_cparam->cparam), n, f, m_projectionMatrix);
+	}
+
+
+        Marker* ARToolKitPlusTracker::getMarker(int markerId) {
+		MarkerList::iterator _end = m_markerlist.end();
+			
+		for (MarkerList::iterator iter = m_markerlist.begin(); 
+			iter != _end; 
+			++iter)		
+		{
+
+			SingleMarker* singleMarker = dynamic_cast<SingleMarker*>((*iter).get());
+			SimpleMarker* simpleMarker = dynamic_cast<SimpleMarker*>((*iter).get());
+			MultiMarker* multiMarker = dynamic_cast<MultiMarker*>((*iter).get());
+
+			if (singleMarker && singleMarker->getPatternID()==markerId)
+                            return singleMarker;
+                        else if (simpleMarker && simpleMarker->getPatternID()==markerId)
+                            return simpleMarker;
+                }
+
+                return NULL;
+
+        }
+
+	void ARToolKitPlusTracker::createUndistortedMesh(
+		int width, int height,
+		float maxU, float maxV,
+		osg::Geometry &geometry)
+	{
+
+		osg::Vec3Array *coords = dynamic_cast<osg::Vec3Array*>(geometry.getVertexArray());
+		osg::Vec2Array* tcoords = dynamic_cast<osg::Vec2Array*>(geometry.getTexCoordArray(0));
+						
+		unsigned int rows = 20, cols = 20;
+		float rowSize = height / (float)rows;
+		float colSize = width / (float)cols;
+		ARFloat x, y, px, py, u, v;
+
+		for (unsigned int r = 0; r < rows; r++) {
+			for (unsigned int c = 0; c <= cols; c++) {
+
+				x = c * colSize;
+				y = r * rowSize;
+
+				m_tracker->getCamera()->observ2Ideal(x, y, &px, &py);
+				coords->push_back(osg::Vec3(px, py, 0.0f));
+
+				u = (c / (float)cols) * maxU;
+				v = (1.0f - (r / (float)rows)) * maxV;
+				tcoords->push_back(osg::Vec2(u, v));
+
+				x = c * colSize;
+				y = (r+1) * rowSize;
+
+				m_tracker->getCamera()->observ2Ideal(x, y, &px, &py);
+				coords->push_back(osg::Vec3(px, py, 0.0f));
+
+				u = (c / (float)cols) * maxU;
+				v = (1.0f - ((r+1) / (float)rows)) * maxV;
+				tcoords->push_back(osg::Vec2(u, v));
+
+			}
+
+			geometry.addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP, 
+				r * 2 * (cols+1), 2 * (cols+1)));
+		}
+	}
+
+}; // namespace osgART
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/gsub.cpp
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/gsub.cpp
@@ -0,0 +1,173 @@
+
+#include <GL/gl.h>
+#include "gsub.h"
+#include <math.h>
+#include <stdio.h>
+
+using namespace ARToolKitPlus;
+
+
+void arglCameraViewRH(const ARFloat para[3][4], GLdouble m_modelview[16], const double scale)
+{
+        m_modelview[0 + 0*4] = para[0][0]; // R1C1
+        m_modelview[0 + 1*4] = para[0][1]; // R1C2
+        m_modelview[0 + 2*4] = para[0][2];
+        m_modelview[0 + 3*4] = para[0][3];
+        m_modelview[1 + 0*4] = -para[1][0]; // R2
+        m_modelview[1 + 1*4] = -para[1][1];
+        m_modelview[1 + 2*4] = -para[1][2];
+        m_modelview[1 + 3*4] = -para[1][3];
+        m_modelview[2 + 0*4] = -para[2][0]; // R3
+        m_modelview[2 + 1*4] = -para[2][1];
+        m_modelview[2 + 2*4] = -para[2][2];
+        m_modelview[2 + 3*4] = -para[2][3];
+        m_modelview[3 + 0*4] = 0.0;
+        m_modelview[3 + 1*4] = 0.0;
+        m_modelview[3 + 2*4] = 0.0;
+        m_modelview[3 + 3*4] = 1.0;
+        if (scale != 0.0) {
+                m_modelview[12] *= scale;
+                m_modelview[13] *= scale;
+                m_modelview[14] *= scale;
+        }
+}
+
+static double norm( double a, double b, double c )
+{
+    return( sqrt( a*a + b*b + c*c ) );
+}
+
+static double dot( double a1, double a2, double a3,
+		   double b1, double b2, double b3 )
+{
+    return( a1 * b1 + a2 * b2 + a3 * b3 );
+}
+
+int  arParamDecompMat( const ARFloat source[3][4], double cpara[3][4], double trans[3][4] )
+{
+    int       r, c;
+    double    Cpara[3][4];
+    double    rem1, rem2, rem3;
+
+    if( source[2][3] >= 0 ) {
+        for( r = 0; r < 3; r++ ){
+	    for( c = 0; c < 4; c++ ){
+                Cpara[r][c] = source[r][c];
+            }
+        }
+    }
+    else {
+        for( r = 0; r < 3; r++ ){
+	    for( c = 0; c < 4; c++ ){
+                Cpara[r][c] = -(source[r][c]);
+            }
+        }
+    }
+
+    for( r = 0; r < 3; r++ ){
+	for( c = 0; c < 4; c++ ){
+            cpara[r][c] = 0.0;
+	}
+    }
+    cpara[2][2] = norm( Cpara[2][0], Cpara[2][1], Cpara[2][2] );
+    trans[2][0] = Cpara[2][0] / cpara[2][2];
+    trans[2][1] = Cpara[2][1] / cpara[2][2];
+    trans[2][2] = Cpara[2][2] / cpara[2][2];
+    trans[2][3] = Cpara[2][3] / cpara[2][2];
+	
+    cpara[1][2] = dot( trans[2][0], trans[2][1], trans[2][2],
+                       Cpara[1][0], Cpara[1][1], Cpara[1][2] );
+    rem1 = Cpara[1][0] - cpara[1][2] * trans[2][0];
+    rem2 = Cpara[1][1] - cpara[1][2] * trans[2][1];
+    rem3 = Cpara[1][2] - cpara[1][2] * trans[2][2];
+    cpara[1][1] = norm( rem1, rem2, rem3 );
+    trans[1][0] = rem1 / cpara[1][1];
+    trans[1][1] = rem2 / cpara[1][1];
+    trans[1][2] = rem3 / cpara[1][1];
+
+    cpara[0][2] = dot( trans[2][0], trans[2][1], trans[2][2],
+                       Cpara[0][0], Cpara[0][1], Cpara[0][2] );
+    cpara[0][1] = dot( trans[1][0], trans[1][1], trans[1][2],
+                       Cpara[0][0], Cpara[0][1], Cpara[0][2] );
+    rem1 = Cpara[0][0] - cpara[0][1]*trans[1][0] - cpara[0][2]*trans[2][0];
+    rem2 = Cpara[0][1] - cpara[0][1]*trans[1][1] - cpara[0][2]*trans[2][1];
+    rem3 = Cpara[0][2] - cpara[0][1]*trans[1][2] - cpara[0][2]*trans[2][2];
+    cpara[0][0] = norm( rem1, rem2, rem3 );
+    trans[0][0] = rem1 / cpara[0][0];
+    trans[0][1] = rem2 / cpara[0][0];
+    trans[0][2] = rem3 / cpara[0][0];
+
+    trans[1][3] = (Cpara[1][3] - cpara[1][2]*trans[2][3]) / cpara[1][1];
+    trans[0][3] = (Cpara[0][3] - cpara[0][1]*trans[1][3]
+                               - cpara[0][2]*trans[2][3]) / cpara[0][0];
+
+    for( r = 0; r < 3; r++ ){
+	for( c = 0; c < 3; c++ ){
+            cpara[r][c] /= cpara[2][2];
+	}
+    }
+
+    return 0;
+}
+
+void arglCameraFrustumRH(const Camera *cparam, const double focalmin, const double focalmax, GLdouble m_projection[16])
+{
+	double   icpara[3][4];
+    double   trans[3][4];
+    double   p[3][3], q[4][4];
+	int      width, height;
+    int      i, j;
+	
+    width  = cparam->xsize;
+    height = cparam->ysize;
+	
+    if (arParamDecompMat(cparam->mat, icpara, trans) < 0) {
+        printf("arglCameraFrustum(): arParamDecompMat() indicated parameter error.\n"); // Windows bug: when running multi-threaded, can't write to stderr!
+        return;
+    }
+	for (i = 0; i < 4; i++) {
+        icpara[1][i] = (height - 1)*(icpara[2][i]) - icpara[1][i];
+    }
+	
+    for(i = 0; i < 3; i++) {
+        for(j = 0; j < 3; j++) {
+            p[i][j] = icpara[i][j] / icpara[2][2];
+        }
+    }
+    q[0][0] = (2.0 * p[0][0] / (width - 1));
+    q[0][1] = (2.0 * p[0][1] / (width - 1));
+    q[0][2] = -((2.0 * p[0][2] / (width - 1))  - 1.0);
+    q[0][3] = 0.0;
+	
+    q[1][0] = 0.0;
+    q[1][1] = -(2.0 * p[1][1] / (height - 1));
+    q[1][2] = -((2.0 * p[1][2] / (height - 1)) - 1.0);
+    q[1][3] = 0.0;
+	
+    q[2][0] = 0.0;
+    q[2][1] = 0.0;
+    q[2][2] = (focalmax + focalmin)/(focalmin - focalmax);
+    q[2][3] = 2.0 * focalmax * focalmin / (focalmin - focalmax);
+	
+    q[3][0] = 0.0;
+    q[3][1] = 0.0;
+    q[3][2] = -1.0;
+    q[3][3] = 0.0;
+	
+    for (i = 0; i < 4; i++) { // Row.
+		// First 3 columns of the current row.
+        for (j = 0; j < 3; j++) { // Column.
+            m_projection[i + j*4] = q[i][0] * trans[0][j] +
+			q[i][1] * trans[1][j] +
+			q[i][2] * trans[2][j];
+        }
+		// Fourth column of the current row.
+        m_projection[i + 3*4] = q[i][0] * trans[0][3] +
+								q[i][1] * trans[1][3] +
+								q[i][2] * trans[2][3] +
+								q[i][3];
+    }	
+}
+
+
+
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/gsub.h
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/gsub.h
@@ -0,0 +1,14 @@
+#ifndef _GSUB_HEADER_
+#define _GSUB_HEADER_
+
+#include <ARToolKitPlus/ar.h>
+#include <ARToolKitPlus/Camera.h>
+
+using namespace ARToolKitPlus;
+
+// this is pretty ugly but just dumping it here...
+void arglCameraViewRH(const ARFloat para[3][4], GLdouble m_modelview[16], const double scale);
+
+void arglCameraFrustumRH(const Camera *cparam, const double focalmin, const double focalmax, GLdouble m_projection[16]);
+
+#endif
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/Main.cpp
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/Main.cpp
@@ -0,0 +1,47 @@
+/*
+ *	osgART/Tracker/ARToolKit/Main
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#include "osgART/VideoPlugin"
+#include "osgART/VideoConfig"
+#include "osgART/GenericVideo"
+
+#include "ARToolKitPlusTracker"
+
+DLL_API osgART::GenericTracker* osgart_create_tracker()
+{
+	return new osgART::ARToolKitPlusTracker();
+}
+
+OSGART_PLUGIN_ENTRY()
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/MultiMarker
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/MultiMarker
@@ -0,0 +1,94 @@
+/*
+ *	osgART/Tracker/ARToolKit/MultiMarker
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#ifndef OSGART_MULTIMARKER
+#define OSGART_MULTIMARKER 1
+
+// STL include
+#include <string>
+#include <vector>
+
+// local include
+#include "osgART/Export"
+#include "osgART/Marker"
+
+// ARToolKit multimarker include
+#include <ARToolKitPlus/Tracker.h>
+
+namespace osgART {
+
+	/**
+	* \class MultiMarker
+	* \brief A marker consisting of many patterns which can be treated as one.
+	*/
+	class MultiMarker : public Marker
+	{
+	public:       
+
+		/** 
+		* \brief default constructor.
+		*
+		*/
+		MultiMarker(ARToolKitPlus::Tracker* tracker);
+	    
+		bool initialise(const std::string& multiFile);
+		
+		virtual void setActive(bool a);
+		
+		void update(ARToolKitPlus::ARMarkerInfo* markerInfo, int markerCount);
+		
+		/**
+		* \brief return the type of the maker.
+		* return if the marker is a single or multi-pattern marker.
+		* \return the type of the marker
+		*/
+		MarkerType getType() const;
+		
+	    
+	protected: 
+	
+		/**
+		* \brief destructor.
+		*/
+		virtual ~MultiMarker();
+
+                ARToolKitPlus::Tracker *m_tracker;
+
+                ARToolKitPlus::ARMultiMarkerInfoT* m_multi;
+			
+	};
+};
+
+#endif
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/MultiMarker.cpp
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/MultiMarker.cpp
@@ -0,0 +1,98 @@
+/*
+ *	osgART/Tracker/ARToolKit/MultiMarker
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#include "MultiMarker"
+
+/*#include <AR/gsub_lite.h>*/
+#include "gsub.h"
+
+//#include <assert.h>
+
+namespace osgART {
+
+	MultiMarker::MultiMarker(ARToolKitPlus::Tracker *tracker) : m_tracker(tracker), Marker() {
+	}
+
+	MultiMarker::~MultiMarker() {   
+		// jcl64: Free the multimarker
+		if (m_multi) m_tracker->arMultiFreeConfig(m_multi);
+	}
+
+	/* virtual */
+	Marker::MarkerType MultiMarker::getType() const {
+		return Marker::ART_MULTI;
+	}
+
+	bool 
+	MultiMarker::initialise(const std::string& multiFile) {
+
+		// Check if multifile exists!!!
+		m_multi = m_tracker->arMultiReadConfigFile(multiFile.c_str());
+		if (m_multi == NULL) return false;
+		
+		setName(multiFile);
+		setActive(false);
+		
+		return true;
+	}
+
+	void
+	MultiMarker::setActive(bool a) {
+		m_active = a;
+
+                // not implemented
+                //assert(0);
+	
+                /*        
+		if (m_active) arMultiActivate(m_multi);
+		else arMultiDeactivate(m_multi);
+                */
+	}
+
+	void 
+	MultiMarker::update(ARToolKitPlus::ARMarkerInfo* markerInfo, int markerCount) 
+	{
+		m_valid = (m_tracker->arMultiGetTransMat(markerInfo, markerCount, m_multi) >= 0);
+		if (m_valid) {
+			double modelView[16];
+			arglCameraViewRH(m_multi->trans, modelView, 1.0); // scale = 1.0.
+			osg::Matrix tmp(modelView);
+			updateTransform(tmp);
+		} else {
+			m_seen = false;
+		}
+	}
+	
+};
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/SimpleMarker
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/SimpleMarker
@@ -0,0 +1,109 @@
+/*
+ *	osgART/Tracker/ARToolKit/SimpleMarker
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#ifndef OSGART_SIMPLEMARKER
+#define OSGART_SIMPLEMARKER 1
+
+// STL include
+#include <string>
+#include <vector>
+
+// local include
+#include "osgART/Export"
+#include "osgART/Marker"
+
+// AR ToolKit include
+//#include <AR/ar.h>
+#include <ARToolKitPlus/Tracker.h>
+
+namespace osgART {
+
+	/**
+	* \class SimpleMarker.
+	* \brief A marker consisting of a single pattern.
+	*/
+	class SimpleMarker : public Marker
+	{
+	public:	
+		
+        virtual bool isSameKindAs(const osg::Object* obj) const {
+            return dynamic_cast<const SimpleMarker*>(obj) != 0L;
+        }
+        virtual const char* className() const { return "SimpleMarker"; }
+        
+    
+		/** 
+		 * \brief default constructor.
+		 *
+		 */
+		SimpleMarker(ARToolKitPlus::Tracker *tracker);
+		
+	    
+		bool initialise(int id, double width, double center[2]);
+
+		virtual void setActive(bool a);
+
+		void update(ARToolKitPlus::ARMarkerInfo* markerInfo);
+		
+		int getPatternID();
+		double getPatternWidth();
+		ARFloat* getPatternCenter();
+
+		
+		MarkerType getType() const;
+	
+	    
+	protected:
+	
+		/**
+		 * \brief destructor.
+		 */
+		virtual ~SimpleMarker();	    
+
+                ARToolKitPlus::Tracker *m_tracker;
+	 
+	    int             patt_id;
+		ARFloat          patt_width;
+		ARFloat          patt_center[2];
+		ARFloat          patt_trans[3][4];
+		
+		double			m_confidence;
+		
+		friend class ARToolKitPlusTracker;
+		
+	};
+};
+
+#endif
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/SimpleMarker.cpp
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/SimpleMarker.cpp
@@ -0,0 +1,126 @@
+/*
+ *	osgART/Tracker/ARToolKit/SimpleMarker
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#include "SimpleMarker"
+
+#include <ARToolKitPlus/Tracker.h>
+/*#include <AR/gsub_lite.h>*/
+#include "gsub.h"
+#include <stdio.h>
+#include <string.h>
+
+namespace osgART {
+
+	SimpleMarker::SimpleMarker(ARToolKitPlus::Tracker *tracker) : m_tracker(tracker), Marker(),
+		patt_id(-1)
+	{
+			m_fields["confidence"] = new TypedField<double>(&m_confidence);
+	}
+
+	SimpleMarker::~SimpleMarker()
+	{
+		// jcl64: Free the pattern
+		//if (patt_id >= 0) m_tracker->arFreePatt(patt_id);
+		//patt_id = -1;
+	}
+
+	Marker::MarkerType SimpleMarker::getType() const
+	{
+		return Marker::ART_SINGLE;
+	}
+
+	bool SimpleMarker::initialise(int id, double width, double center[2])
+	{
+            char name[1024];
+
+
+            //printf("1: patt_id=%d\n",patt_id);
+		if (patt_id >= 0) return (false);
+		patt_id = id;
+            //printf("2: patt_id=%d\n",patt_id);
+		if (patt_id < 0) return false;
+		patt_width = width;
+		patt_center[0] = center[0];
+		patt_center[1] = center[1];
+                snprintf(name,1024,"simple%d",patt_id);
+		setName(name);
+		setActive(false);
+            //printf("3: patt_id=%d\n",patt_id);
+		return true;
+	}
+
+	void SimpleMarker::update(ARToolKitPlus::ARMarkerInfo* markerInfo)
+	{
+		if (markerInfo == 0L) {
+			m_valid = false;
+			m_seen = false;
+		} else {
+			m_valid = true;
+			//arGetTransMatCont(markerInfo, patt_trans, patt_center, patt_width, patt_trans);
+			m_tracker->arGetTransMat(markerInfo, patt_center, patt_width, patt_trans);
+			m_confidence = markerInfo->cf;
+			double modelView[16];
+			arglCameraViewRH(patt_trans, modelView, 1.0); // scale = 1.0.
+			osg::Matrix tmp(modelView);
+			updateTransform(tmp);
+		}
+	}
+
+	void SimpleMarker::setActive(bool a)
+	{
+		m_active = a;
+	
+        /*        
+		if (m_active) arActivatePatt(patt_id);
+		else arDeactivatePatt(patt_id);
+                */
+
+	}
+
+	int SimpleMarker::getPatternID()
+	{
+		return patt_id;
+	}
+
+	double SimpleMarker::getPatternWidth()
+	{
+		return patt_width;
+	}
+		
+	ARFloat* SimpleMarker::getPatternCenter()
+	{
+		return patt_center;
+	}
+};
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/SingleMarker
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/SingleMarker
@@ -0,0 +1,109 @@
+/*
+ *	osgART/Tracker/ARToolKit/SingleMarker
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#ifndef OSGART_SINGLEMARKER
+#define OSGART_SINGLEMARKER 1
+
+// STL include
+#include <string>
+#include <vector>
+
+// local include
+#include "osgART/Export"
+#include "osgART/Marker"
+
+// AR ToolKit include
+//#include <AR/ar.h>
+#include <ARToolKitPlus/Tracker.h>
+
+namespace osgART {
+
+	/**
+	* \class SingleMarker.
+	* \brief A marker consisting of a single pattern.
+	*/
+	class SingleMarker : public Marker
+	{
+	public:	
+		
+        virtual bool isSameKindAs(const osg::Object* obj) const {
+            return dynamic_cast<const SingleMarker*>(obj) != 0L;
+        }
+        virtual const char* className() const { return "SingleMarker"; }
+        
+    
+		/** 
+		 * \brief default constructor.
+		 *
+		 */
+		SingleMarker(ARToolKitPlus::Tracker *tracker);
+		
+	    
+		bool initialise(const std::string& pattFile, double width, double center[2]);
+
+		virtual void setActive(bool a);
+
+		void update(ARToolKitPlus::ARMarkerInfo* markerInfo);
+		
+		int getPatternID();
+		double getPatternWidth();
+		ARFloat* getPatternCenter();
+
+		
+		MarkerType getType() const;
+	
+	    
+	protected:
+	
+		/**
+		 * \brief destructor.
+		 */
+		virtual ~SingleMarker();	    
+
+                ARToolKitPlus::Tracker *m_tracker;
+	 
+	    int             patt_id;
+		ARFloat          patt_width;
+		ARFloat          patt_center[2];
+		ARFloat          patt_trans[3][4];
+		
+		double			m_confidence;
+		
+		friend class ARToolKitPlusTracker;
+		
+	};
+};
+
+#endif
Index: osgART-1.0/src/osgART/Tracker/ARToolKitPlus/SingleMarker.cpp
===================================================================
--- /dev/null
+++ osgART-1.0/src/osgART/Tracker/ARToolKitPlus/SingleMarker.cpp
@@ -0,0 +1,125 @@
+/*
+ *	osgART/Tracker/ARToolKit/SingleMarker
+ *	osgART: AR ToolKit for OpenSceneGraph
+ *
+ *	Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *	
+ *	Rev		Date		Who		Changes
+ *  1.0   	2006-12-08  ---     Version 1.0 release.
+ *
+ */
+/*
+ * This file is part of osgART - AR Toolkit for OpenSceneGraph
+ *
+ * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved.
+ *
+ * (See the AUTHORS file in the root of this distribution.)
+ *
+ *
+ * OSGART is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * OSGART is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OSGART; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#include "SingleMarker"
+
+#include <ARToolKitPlus/Tracker.h>
+/*#include <AR/gsub_lite.h>*/
+#include "gsub.h"
+#include <string.h>
+
+namespace osgART {
+
+	SingleMarker::SingleMarker(ARToolKitPlus::Tracker *tracker) : m_tracker(tracker), Marker(),
+		patt_id(-1)
+	{
+			m_fields["confidence"] = new TypedField<double>(&m_confidence);
+	}
+
+	SingleMarker::~SingleMarker()
+	{
+		// jcl64: Free the pattern
+		if (patt_id >= 0) m_tracker->arFreePatt(patt_id);
+		patt_id = -1;
+	}
+
+	Marker::MarkerType SingleMarker::getType() const
+	{
+		return Marker::ART_SINGLE;
+	}
+
+	bool SingleMarker::initialise(const std::string& pattFile, double width, double center[2])
+	{
+            char str[1024];
+
+            printf("1: patt_id=%d\n",patt_id);
+		if (patt_id >= 0) return (false);
+                // danged const..
+                strncpy(str,pattFile.c_str(),1024);
+		patt_id = m_tracker->arLoadPatt(str);
+            printf("2: patt_id=%d\n",patt_id);
+		if (patt_id < 0) return false;
+		patt_width = width;
+		patt_center[0] = center[0];
+		patt_center[1] = center[1];
+		setName(pattFile);
+		setActive(false);
+            printf("3: patt_id=%d\n",patt_id);
+		return true;
+	}
+
+	void SingleMarker::update(ARToolKitPlus::ARMarkerInfo* markerInfo)
+	{
+		if (markerInfo == 0L) {
+			m_valid = false;
+			m_seen = false;
+		} else {
+			m_valid = true;
+			//arGetTransMatCont(markerInfo, patt_trans, patt_center, patt_width, patt_trans);
+			m_tracker->arGetTransMat(markerInfo, patt_center, patt_width, patt_trans);
+			m_confidence = markerInfo->cf;
+			double modelView[16];
+			arglCameraViewRH(patt_trans, modelView, 1.0); // scale = 1.0.
+			osg::Matrix tmp(modelView);
+			updateTransform(tmp);
+		}
+	}
+
+	void SingleMarker::setActive(bool a)
+	{
+		m_active = a;
+	
+        /*        
+		if (m_active) arActivatePatt(patt_id);
+		else arDeactivatePatt(patt_id);
+                */
+
+	}
+
+	int SingleMarker::getPatternID()
+	{
+		return patt_id;
+	}
+
+	double SingleMarker::getPatternWidth()
+	{
+		return patt_width;
+	}
+		
+	ARFloat* SingleMarker::getPatternCenter()
+	{
+		return patt_center;
+	}
+};
openSUSE Build Service is sponsored by