TrackerSingleMarkerImpl.h
Go to the documentation of this file.
1 /* ========================================================================
2 * PROJECT: ARToolKitPlus
3 * ========================================================================
4 * This work is based on the original ARToolKit developed by
5 * Hirokazu Kato
6 * Mark Billinghurst
7 * HITLab, University of Washington, Seattle
8 * http://www.hitl.washington.edu/artoolkit/
9 *
10 * Copyright of the derived and new portions of this work
11 * (C) 2006 Graz University of Technology
12 *
13 * This framework is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This framework is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this framework; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * For further information please contact
28 * Dieter Schmalstieg
29 * <schmalstieg@icg.tu-graz.ac.at>
30 * Graz University of Technology,
31 * Institut for Computer Graphics and Vision,
32 * Inffeldgasse 16a, 8010 Graz, Austria.
33 * ========================================================================
34 ** @author Daniel Wagner
35 *
36 * $Id: TrackerSingleMarkerImpl.h 172 2006-07-25 14:05:47Z daniel $
37 * @file
38 * ======================================================================= */
39 
40 
41 #ifndef __ARTOOLKITPLUS_TRACKERSINGLEMARKERIMPL_HEADERFILE__
42 #define __ARTOOLKITPLUS_TRACKERSINGLEMARKERIMPL_HEADERFILE__
43 
44 //#pragma message ( "Compiling TrackerSingleMarkerImpl.h" )
45 
46 
49 #include <ARToolKitPlus/Logger.h>
50 
51 
52 #define ARSM_TEMPL_FUNC template <int __PATTERN_SIZE_X, int __PATTERN_SIZE_Y, int __PATTERN_SAMPLE_NUM, int __MAX_LOAD_PATTERNS, int __MAX_IMAGE_PATTERNS>
53 #define ARSM_TEMPL_TRACKER TrackerSingleMarkerImpl<__PATTERN_SIZE_X, __PATTERN_SIZE_Y, __PATTERN_SAMPLE_NUM, __MAX_LOAD_PATTERNS, __MAX_IMAGE_PATTERNS>
54 
55 
56 namespace ARToolKitPlus
57 {
58 
59 
61 
70 template <int __PATTERN_SIZE_X, int __PATTERN_SIZE_Y, int __PATTERN_SAMPLE_NUM, int __MAX_LOAD_PATTERNS=32, int __MAX_IMAGE_PATTERNS=32>
71 class TrackerSingleMarkerImpl : public TrackerSingleMarker, protected TrackerImpl<__PATTERN_SIZE_X,__PATTERN_SIZE_Y, __PATTERN_SAMPLE_NUM, __MAX_LOAD_PATTERNS, __MAX_IMAGE_PATTERNS>
72 {
73 public:
74  TrackerSingleMarkerImpl(int nWidth=DEF_CAMWIDTH, int nHeight=DEF_CAMHEIGHT);
76 
78 
82  virtual bool init(const char* nCamParamFile, ARFloat nNearClip, ARFloat nFarClip, ARToolKitPlus::Logger* nLogger=NULL);
83  virtual bool init(Camera* camera, ARFloat nNearClip, ARFloat nFarClip, ARToolKitPlus::Logger* nLogger=NULL);
84 
86 
89  virtual int addPattern(const char* nFileName);
90 
92 
97  virtual int calc(const unsigned char* nImage, int nPattern=-1, bool nUpdateMatrix=true,
98  ARMarkerInfo** nMarker_info=NULL, int* nNumMarkers=NULL);
99 
101  virtual void setPatternWidth(ARFloat nWidth) { patt_width = nWidth; }
102 
104 
110  virtual void getARMatrix(ARFloat nMatrix[3][4]) const;
111 
113  virtual ARFloat getConfidence() const { return confidence; }
114 
115 
116  //
117  // reimplement TrackerImpl into TrackerSingleMarker interface
118  //
119  // TODO: something like 'using cleanup;' would be nicer but does seem to work...
120  //
122  bool setPixelFormat(PIXEL_FORMAT nFormat) { return AR_TEMPL_TRACKER::setPixelFormat(nFormat); }
123  bool loadCameraFile(const char* nCamParamFile, ARFloat nNearClip, ARFloat nFarClip) { return AR_TEMPL_TRACKER::loadCameraFile(nCamParamFile, nNearClip, nFarClip); }
124  void setLoadUndistLUT(bool nSet) { AR_TEMPL_TRACKER::setLoadUndistLUT(nSet); }
125  void setLogger(ARToolKitPlus::Logger* nLogger) { AR_TEMPL_TRACKER::setLogger(nLogger); }
126  int arDetectMarker(ARUint8 *dataPtr, int thresh, ARMarkerInfo **marker_info, int *marker_num) { return AR_TEMPL_TRACKER::arDetectMarker(dataPtr, thresh, marker_info, marker_num); }
127  int arDetectMarkerLite(ARUint8 *dataPtr, int thresh, ARMarkerInfo **marker_info, int *marker_num) { return AR_TEMPL_TRACKER::arDetectMarkerLite(dataPtr, thresh, marker_info, marker_num); }
128  ARFloat arMultiGetTransMat(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config) { return AR_TEMPL_TRACKER::arMultiGetTransMat(marker_info, marker_num, config); }
129  ARFloat arGetTransMat(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4]) { return AR_TEMPL_TRACKER::arGetTransMat(marker_info, center, width, conv); }
130  ARFloat arGetTransMatCont(ARMarkerInfo *marker_info, ARFloat prev_conv[3][4], ARFloat center[2], ARFloat width, ARFloat conv[3][4]) { return AR_TEMPL_TRACKER::arGetTransMatCont(marker_info, prev_conv, center, width, conv); }
131  ARFloat rppMultiGetTransMat(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config) { return AR_TEMPL_TRACKER::rppMultiGetTransMat(marker_info, marker_num, config); }
132  ARFloat rppGetTransMat(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4]) { return AR_TEMPL_TRACKER::rppGetTransMat(marker_info, center, width, conv); }
133  int arLoadPatt(char *filename) { return AR_TEMPL_TRACKER::arLoadPatt(filename); }
134  int arFreePatt(int patno) { return AR_TEMPL_TRACKER::arFreePatt(patno); }
135  int arMultiFreeConfig(ARMultiMarkerInfoT *config) { return AR_TEMPL_TRACKER::arMultiFreeConfig(config); }
136  ARMultiMarkerInfoT *arMultiReadConfigFile(const char *filename) { return AR_TEMPL_TRACKER::arMultiReadConfigFile(filename); }
137  void activateBinaryMarker(int nThreshold) { AR_TEMPL_TRACKER::activateBinaryMarker(nThreshold); }
138  void setMarkerMode(MARKER_MODE nMarkerMode) { AR_TEMPL_TRACKER::setMarkerMode(nMarkerMode); }
139  void activateVignettingCompensation(bool nEnable, int nCorners=0, int nLeftRight=0, int nTopBottom=0) { AR_TEMPL_TRACKER::activateVignettingCompensation(nEnable, nCorners, nLeftRight, nTopBottom); }
140  void changeCameraSize(int nWidth, int nHeight) { AR_TEMPL_TRACKER::changeCameraSize(nWidth, nHeight); }
141  void setUndistortionMode(UNDIST_MODE nMode) { AR_TEMPL_TRACKER::setUndistortionMode(nMode); }
142  bool setPoseEstimator(POSE_ESTIMATOR nMethod) { return AR_TEMPL_TRACKER::setPoseEstimator(nMethod); }
143  void setBorderWidth(ARFloat nFraction) { AR_TEMPL_TRACKER::setBorderWidth(nFraction); }
144  void setThreshold(int nValue) { AR_TEMPL_TRACKER::setThreshold(nValue); }
145  int getThreshold() const { return AR_TEMPL_TRACKER::getThreshold(); }
146  void activateAutoThreshold(bool nEnable) { AR_TEMPL_TRACKER::activateAutoThreshold(nEnable); }
147  bool isAutoThresholdActivated() const { return AR_TEMPL_TRACKER::isAutoThresholdActivated(); }
148  void setNumAutoThresholdRetries(int nNumRetries) { AR_TEMPL_TRACKER::setNumAutoThresholdRetries(nNumRetries); }
149  const ARFloat* getModelViewMatrix() const { return AR_TEMPL_TRACKER::getModelViewMatrix(); }
150  const ARFloat* getProjectionMatrix() const { return AR_TEMPL_TRACKER::getProjectionMatrix(); }
151  const char* getDescription() { return AR_TEMPL_TRACKER::getDescription(); }
152  PIXEL_FORMAT getPixelFormat() const { return static_cast<PIXEL_FORMAT>(AR_TEMPL_TRACKER::getPixelFormat()); }
153  int getBitsPerPixel() const { return static_cast<PIXEL_FORMAT>(AR_TEMPL_TRACKER::getBitsPerPixel()); }
154  int getNumLoadablePatterns() const { return AR_TEMPL_TRACKER::getNumLoadablePatterns(); }
155  void setImageProcessingMode(IMAGE_PROC_MODE nMode) { AR_TEMPL_TRACKER::setImageProcessingMode(nMode); }
156  Profiler& getProfiler() { return AR_TEMPL_TRACKER::getProfiler(); }
157  Camera* getCamera() { return AR_TEMPL_TRACKER::getCamera(); }
158  void setCamera(Camera* nCamera) { AR_TEMPL_TRACKER::setCamera(nCamera); }
159  void setCamera(Camera* nCamera, ARFloat nNearClip, ARFloat nFarClip) { AR_TEMPL_TRACKER::setCamera(nCamera, nNearClip, nFarClip); }
160  ARFloat calcOpenGLMatrixFromMarker(ARMarkerInfo* nMarkerInfo, ARFloat nPatternCenter[2], ARFloat nPatternSize, ARFloat *nOpenGLMatrix) { return AR_TEMPL_TRACKER::calcOpenGLMatrixFromMarker(nMarkerInfo, nPatternCenter, nPatternSize, nOpenGLMatrix); }
161  ARFloat executeSingleMarkerPoseEstimator(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4]) { return AR_TEMPL_TRACKER::executeSingleMarkerPoseEstimator(marker_info, center, width, conv); }
162  ARFloat executeMultiMarkerPoseEstimator(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config) { return AR_TEMPL_TRACKER::executeMultiMarkerPoseEstimator(marker_info, marker_num, config); }
163 
164 
165  static void* operator new(size_t size);
166 
167  static void operator delete(void *rawMemory);
168 
169  static size_t getMemoryRequirements();
170 
171 protected:
176 };
177 
178 
179 } // namespace ARToolKitPlus
180 
181 #include "../src/TrackerSingleMarkerImpl.cxx"
182 
183 
184 #endif //__ARTOOLKITPLUS_TRACKERSINGLEMARKERIMPL_HEADERFILE__
const ARFloat * getProjectionMatrix() const
Returns an opengl-style projection transformation matrix.
bool setPoseEstimator(POSE_ESTIMATOR nMethod)
Changes the Pose Estimation Algorithm.
int getThreshold() const
Returns the current threshold value.
void activateVignettingCompensation(bool nEnable, int nCorners=0, int nLeftRight=0, int nTopBottom=0)
activates the complensation of brightness falloff in the corners of the camera image ...
int getBitsPerPixel() const
Returns the numbber of bits per pixel for the compiled-in pixel format.
static void cleanup(void)
virtual void getARMatrix(ARFloat nMatrix[3][4]) const
Provides access to ARToolKit&#39; patt_trans matrix.
void activateAutoThreshold(bool nEnable)
Turns automatic threshold calculation on/off.
void setBorderWidth(ARFloat nFraction)
Sets a new relative border width. ARToolKit&#39;s default value is 0.25.
ARFloat executeMultiMarkerPoseEstimator(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config)
Calls the pose estimator set with setPoseEstimator() for multi marker tracking.
const char * getDescription()
Returns a short description with compiled-in settings.
void setNumAutoThresholdRetries(int nNumRetries)
Sets the number of times the threshold is randomized in case no marker was visible (Minimum: 1...
virtual ARFloat getConfidence() const
Returns the confidence value of the currently best detected marker.
int arFreePatt(int patno)
frees a pattern from memory
TrackerSingleMarkerImpl implements the TrackerSingleMarker interface.
void setLoadUndistLUT(bool nSet)
Set to true to try loading camera undistortion table from a cache file.
int arLoadPatt(char *filename)
loads a pattern from a file
ARFloat executeSingleMarkerPoseEstimator(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4])
Calls the pose estimator set with setPoseEstimator() for single marker tracking.
virtual bool init(const char *nCamParamFile, ARFloat nNearClip, ARFloat nFarClip, ARToolKitPlus::Logger *nLogger=NULL)
initializes TrackerSingleMarker
Camera * getCamera()
Returns the current camera.
ARFloat calcOpenGLMatrixFromMarker(ARMarkerInfo *nMarkerInfo, ARFloat nPatternCenter[2], ARFloat nPatternSize, ARFloat *nOpenGLMatrix)
Calculates the OpenGL transformation matrix for a specific marker info.
This file should only be compiled when using ARToolKitPlus as a DLL.
Definition: ar.h:60
int getNumLoadablePatterns() const
Returns the maximum number of patterns that can be loaded.
void activateBinaryMarker(int nThreshold)
activates binary markers
ARFloat rppGetTransMat(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4])
unsigned char ARUint8
Definition: ar.h:66
ARFileGrabber camera("dump_%02d.raw", CAM_W, CAM_H, 4)
ARMultiMarkerInfoT * arMultiReadConfigFile(const char *filename)
reads a standard artoolkit multimarker config file
void setImageProcessingMode(IMAGE_PROC_MODE nMode)
Sets an image processing mode (half or full resolution)
PIXEL_FORMAT getPixelFormat() const
Returns the compiled-in pixel format.
void setCamera(Camera *nCamera)
Sets a new camera without specifying new near and far clip values.
void setMarkerMode(MARKER_MODE nMarkerMode)
Activate the usage of id-based markers rather than template based markers.
void setCamera(Camera *nCamera, ARFloat nNearClip, ARFloat nFarClip)
Sets a new camera including specifying new near and far clip values.
TrackerSingleMarkerImpl(int nWidth=DEF_CAMWIDTH, int nHeight=DEF_CAMHEIGHT)
ARFloat arGetTransMatCont(ARMarkerInfo *marker_info, ARFloat prev_conv[3][4], ARFloat center[2], ARFloat width, ARFloat conv[3][4])
void cleanup()
does final clean up (memory deallocation)
Defines a simple interface for single-marker tracking with ARToolKitPlus.
int arDetectMarker(ARUint8 *dataPtr, int thresh, ARMarkerInfo **marker_info, int *marker_num)
marker detection using tracking history
ARFloat arMultiGetTransMat(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config)
calculates the transformation matrix between camera and the given multi-marker config ...
virtual int calc(const unsigned char *nImage, int nPattern=-1, bool nUpdateMatrix=true, ARMarkerInfo **nMarker_info=NULL, int *nNumMarkers=NULL)
calculates the transformation matrix
void setUndistortionMode(UNDIST_MODE nMode)
Changes the undistortion mode.
ARToolKit::Logger specifies the interface for a logging application.
Definition: Logger.h:61
#define NULL
Definition: PocketKnife.h:38
bool isAutoThresholdActivated() const
Returns true if automatic threshold detection is enabled.
const ARFloat * getModelViewMatrix() const
Returns an opengl-style modelview transformation matrix.
Profiler & getProfiler()
Returns the internal profiler object.
int arMultiFreeConfig(ARMultiMarkerInfoT *config)
frees a multimarker config from memory
void setLogger(ARToolKitPlus::Logger *nLogger)
sets an instance which implements the ARToolKit::Logger interface
TrackerImpl implements the Tracker interface.
Definition: TrackerImpl.h:94
virtual void setPatternWidth(ARFloat nWidth)
Sets the width and height of the patterns.
ARFloat rppMultiGetTransMat(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config)
void setThreshold(int nValue)
Sets the threshold value that is used for black/white conversion.
float ARFloat
Definition: config.h:60
virtual int addPattern(const char *nFileName)
adds a pattern to ARToolKit
bool loadCameraFile(const char *nCamParamFile, ARFloat nNearClip, ARFloat nFarClip)
Loads a camera calibration file and stores data internally.
void changeCameraSize(int nWidth, int nHeight)
Changes the resolution of the camera after the camerafile was already loaded.
bool setPixelFormat(PIXEL_FORMAT nFormat)
Sets the pixel format of the camera image.
ARFloat arGetTransMat(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4])
calculates the transformation matrix between camera and the given marker
int arDetectMarkerLite(ARUint8 *dataPtr, int thresh, ARMarkerInfo **marker_info, int *marker_num)
marker detection without using tracking history


tuw_artoolkitplus
Author(s): Markus Bader
autogenerated on Sun Sep 4 2016 03:24:33