TrackerMultiMarkerImpl.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: TrackerMultiMarkerImpl.h 172 2006-07-25 14:05:47Z daniel $
37 * @file
38 * ======================================================================== */
39 
40 
41 #ifndef __ARTOOLKITPLUS_TRACKERMULTIMARKERIMPL_HEADERFILE__
42 #define __ARTOOLKITPLUS_TRACKERMULTIMARKERIMPL_HEADERFILE__
43 
44 
47 #include <ARToolKitPlus/Logger.h>
48 
49 
50 #define ARMM_TEMPL_FUNC template <int __PATTERN_SIZE_X, int __PATTERN_SIZE_Y, int __PATTERN_SAMPLE_NUM, int __MAX_LOAD_PATTERNS, int __MAX_IMAGE_PATTERNS>
51 #define ARMM_TEMPL_TRACKER TrackerMultiMarkerImpl<__PATTERN_SIZE_X, __PATTERN_SIZE_Y, __PATTERN_SAMPLE_NUM, __MAX_LOAD_PATTERNS, __MAX_IMAGE_PATTERNS>
52 
53 
54 namespace ARToolKitPlus
55 {
56 
57 
59 
68 template <int __PATTERN_SIZE_X, int __PATTERN_SIZE_Y, int __PATTERN_SAMPLE_NUM, int __MAX_LOAD_PATTERNS=32, int __MAX_IMAGE_PATTERNS=32>
69 class TrackerMultiMarkerImpl : public TrackerMultiMarker, protected TrackerImpl<__PATTERN_SIZE_X,__PATTERN_SIZE_Y, __PATTERN_SAMPLE_NUM, __MAX_LOAD_PATTERNS, __MAX_IMAGE_PATTERNS>
70 {
71 public:
72  TrackerMultiMarkerImpl(int nWidth=320, int nHeight=240);
74 
77 
82  virtual bool init(const char* nCamParamFile, const char* nMultiFile, ARFloat nNearClip, ARFloat nFarClip,
83  ARToolKitPlus::Logger* nLogger=NULL);
84  virtual bool init(Camera* camera, const char* nMultiFile, ARFloat nNearClip, ARFloat nFarClip,
85  ARToolKitPlus::Logger* nLogger=NULL);
86 
88 
91  virtual int calc(const unsigned char* nImage);
92 
94  virtual int getNumDetectedMarkers() const { return numDetected; }
95 
97 
102  virtual void setUseDetectLite(bool nEnable) { useDetectLite = nEnable; }
103 
104  virtual void getDetectedMarkers(int*& nMarkerIDs);
105 
106  virtual const ARMarkerInfo& getDetectedMarker(int nWhich) const { return detectedMarkers[nWhich]; }
107 
108  virtual const ARMultiMarkerInfoT* getMultiMarkerConfig() const { return config; }
109 
111 
117  virtual void getARMatrix(ARFloat nMatrix[3][4]) const;
118 
119 
120  //
121  // reimplement TrackerImpl into TrackerSingleMarker interface
122  //
123  // TODO: something like 'using cleanup;' would be nicer but does seem to work...
124  //
126  bool setPixelFormat(PIXEL_FORMAT nFormat) { return AR_TEMPL_TRACKER::setPixelFormat(nFormat); }
127  bool loadCameraFile(const char* nCamParamFile, ARFloat nNearClip, ARFloat nFarClip) { return AR_TEMPL_TRACKER::loadCameraFile(nCamParamFile, nNearClip, nFarClip); }
128  void setLoadUndistLUT(bool nSet) { AR_TEMPL_TRACKER::setLoadUndistLUT(nSet); }
129  void setLogger(ARToolKitPlus::Logger* nLogger) { AR_TEMPL_TRACKER::setLogger(nLogger); }
130  int arDetectMarker(ARUint8 *dataPtr, int thresh, ARMarkerInfo **marker_info, int *marker_num) { return AR_TEMPL_TRACKER::arDetectMarker(dataPtr, thresh, marker_info, marker_num); }
131  int arDetectMarkerLite(ARUint8 *dataPtr, int thresh, ARMarkerInfo **marker_info, int *marker_num) { return AR_TEMPL_TRACKER::arDetectMarkerLite(dataPtr, thresh, marker_info, marker_num); }
132  ARFloat arMultiGetTransMat(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config) { return AR_TEMPL_TRACKER::arMultiGetTransMat(marker_info, marker_num, config); }
133  ARFloat arGetTransMat(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4]) { return AR_TEMPL_TRACKER::arGetTransMat(marker_info, center, width, conv); }
134  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); }
135  ARFloat rppMultiGetTransMat(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config) { return AR_TEMPL_TRACKER::rppMultiGetTransMat(marker_info, marker_num, config); }
136  ARFloat rppGetTransMat(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4]) { return AR_TEMPL_TRACKER::rppGetTransMat(marker_info, center, width, conv); }
137  int arLoadPatt(char *filename) { return AR_TEMPL_TRACKER::arLoadPatt(filename); }
138  int arFreePatt(int patno) { return AR_TEMPL_TRACKER::arFreePatt(patno); }
139  int arMultiFreeConfig(ARMultiMarkerInfoT *config) { return AR_TEMPL_TRACKER::arMultiFreeConfig(config); }
140  ARMultiMarkerInfoT *arMultiReadConfigFile(const char *filename) { return AR_TEMPL_TRACKER::arMultiReadConfigFile(filename); }
141  void activateBinaryMarker(int nThreshold) { AR_TEMPL_TRACKER::activateBinaryMarker(nThreshold); }
142  void setMarkerMode(MARKER_MODE nMarkerMode) { AR_TEMPL_TRACKER::setMarkerMode(nMarkerMode); }
143  void activateVignettingCompensation(bool nEnable, int nCorners=0, int nLeftRight=0, int nTopBottom=0) { AR_TEMPL_TRACKER::activateVignettingCompensation(nEnable, nCorners, nLeftRight, nTopBottom); }
144  void changeCameraSize(int nWidth, int nHeight) { AR_TEMPL_TRACKER::changeCameraSize(nWidth, nHeight); }
145  void setUndistortionMode(UNDIST_MODE nMode) { AR_TEMPL_TRACKER::setUndistortionMode(nMode); }
146  bool setPoseEstimator(POSE_ESTIMATOR nMethod) { return AR_TEMPL_TRACKER::setPoseEstimator(nMethod); }
147  void setBorderWidth(ARFloat nFraction) { AR_TEMPL_TRACKER::setBorderWidth(nFraction); }
148  void setThreshold(int nValue) { AR_TEMPL_TRACKER::setThreshold(nValue); }
149  int getThreshold() const { return AR_TEMPL_TRACKER::getThreshold(); }
150  void activateAutoThreshold(bool nEnable) { AR_TEMPL_TRACKER::activateAutoThreshold(nEnable); }
151  bool isAutoThresholdActivated() const { return AR_TEMPL_TRACKER::isAutoThresholdActivated(); }
152  void setNumAutoThresholdRetries(int nNumRetries) { AR_TEMPL_TRACKER::setNumAutoThresholdRetries(nNumRetries); }
153  const ARFloat* getModelViewMatrix() const { return AR_TEMPL_TRACKER::getModelViewMatrix(); }
154  const ARFloat* getProjectionMatrix() const { return AR_TEMPL_TRACKER::getProjectionMatrix(); }
155  const char* getDescription() { return AR_TEMPL_TRACKER::getDescription(); }
156  PIXEL_FORMAT getPixelFormat() const { return static_cast<PIXEL_FORMAT>(AR_TEMPL_TRACKER::getPixelFormat()); }
157  int getBitsPerPixel() const { return static_cast<PIXEL_FORMAT>(AR_TEMPL_TRACKER::getBitsPerPixel()); }
158  int getNumLoadablePatterns() const { return AR_TEMPL_TRACKER::getNumLoadablePatterns(); }
159  void setImageProcessingMode(IMAGE_PROC_MODE nMode) { AR_TEMPL_TRACKER::setImageProcessingMode(nMode); }
160  Profiler& getProfiler() { return AR_TEMPL_TRACKER::getProfiler(); }
161  Camera* getCamera() { return AR_TEMPL_TRACKER::getCamera(); }
162  void setCamera(Camera* nCamera) { AR_TEMPL_TRACKER::setCamera(nCamera); }
163  void setCamera(Camera* nCamera, ARFloat nNearClip, ARFloat nFarClip) { AR_TEMPL_TRACKER::setCamera(nCamera, nNearClip, nFarClip); }
164  ARFloat calcOpenGLMatrixFromMarker(ARMarkerInfo* nMarkerInfo, ARFloat nPatternCenter[2], ARFloat nPatternSize, ARFloat *nOpenGLMatrix) { return AR_TEMPL_TRACKER::calcOpenGLMatrixFromMarker(nMarkerInfo, nPatternCenter, nPatternSize, nOpenGLMatrix); }
165  ARFloat executeSingleMarkerPoseEstimator(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4]) { return AR_TEMPL_TRACKER::executeSingleMarkerPoseEstimator(marker_info, center, width, conv); }
166  ARFloat executeMultiMarkerPoseEstimator(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config) { return AR_TEMPL_TRACKER::executeMultiMarkerPoseEstimator(marker_info, marker_num, config); }
167 
168  static void* operator new(size_t size);
169 
170  static void operator delete(void *rawMemory);
171 
172  static size_t getMemoryRequirements();
173 
174 protected:
177 
179 
180  int detectedMarkerIDs[AR_TEMPL_TRACKER::MAX_IMAGE_PATTERNS];
181  ARMarkerInfo detectedMarkers[AR_TEMPL_TRACKER::MAX_IMAGE_PATTERNS];
182 };
183 
184 
185 }; // namespace ARToolKitPlus
186 
187 
188 #include "../src/TrackerMultiMarkerImpl.cxx"
189 
190 
191 #endif //__ARTOOLKITPLUS_TRACKERMULTIMARKERIMPL_HEADERFILE__
ARFloat arMultiGetTransMat(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config)
calculates the transformation matrix between camera and the given multi-marker config ...
virtual int getNumDetectedMarkers() const
Returns the number of detected markers used for multi-marker tracking.
PIXEL_FORMAT getPixelFormat() const
Returns the compiled-in pixel format.
Camera * getCamera()
Returns the current camera.
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.
void changeCameraSize(int nWidth, int nHeight)
Changes the resolution of the camera after the camerafile was already loaded.
const char * getDescription()
Returns a short description with compiled-in settings.
void setCamera(Camera *nCamera)
Sets a new camera without specifying new near and far clip values.
void setThreshold(int nValue)
Sets the threshold value that is used for black/white conversion.
virtual void setUseDetectLite(bool nEnable)
Enables usage of arDetectMarkerLite. Otherwise arDetectMarker is used.
TrackerMultiMarkerImpl(int nWidth=320, int nHeight=240)
virtual void getARMatrix(ARFloat nMatrix[3][4]) const
Provides access to ARToolKit&#39; internal version of the transformation matrix.
static void cleanup(void)
const ARFloat * getModelViewMatrix() const
Returns an opengl-style modelview transformation matrix.
void setLoadUndistLUT(bool nSet)
Set to true to try loading camera undistortion table from a cache file.
ARFloat rppMultiGetTransMat(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config)
bool loadCameraFile(const char *nCamParamFile, ARFloat nNearClip, ARFloat nFarClip)
Loads a camera calibration file and stores data internally.
void setImageProcessingMode(IMAGE_PROC_MODE nMode)
Sets an image processing mode (half or full resolution)
Profiler & getProfiler()
Returns the internal profiler object.
bool setPixelFormat(PIXEL_FORMAT nFormat)
Sets the pixel format of the camera image.
int getThreshold() const
Returns the current threshold value.
void activateBinaryMarker(int nThreshold)
activates binary markers
Defines a simple interface for multi-marker tracking with ARToolKitPlus.
virtual bool init(const char *nCamParamFile, const char *nMultiFile, ARFloat nNearClip, ARFloat nFarClip, ARToolKitPlus::Logger *nLogger=NULL)
ARMarkerInfo detectedMarkers[AR_TEMPL_TRACKER::MAX_IMAGE_PATTERNS]
int detectedMarkerIDs[AR_TEMPL_TRACKER::MAX_IMAGE_PATTERNS]
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 ...
void cleanup()
does final clean up (memory deallocation)
This file should only be compiled when using ARToolKitPlus as a DLL.
Definition: ar.h:60
void setNumAutoThresholdRetries(int nNumRetries)
Sets the number of times the threshold is randomized in case no marker was visible (Minimum: 1...
TrackerMultiMarkerImpl implements the TrackerMultiMarker interface.
int arDetectMarker(ARUint8 *dataPtr, int thresh, ARMarkerInfo **marker_info, int *marker_num)
marker detection using tracking history
bool setPoseEstimator(POSE_ESTIMATOR nMethod)
Changes the Pose Estimation Algorithm.
unsigned char ARUint8
Definition: ar.h:66
ARFileGrabber camera("dump_%02d.raw", CAM_W, CAM_H, 4)
ARFloat calcOpenGLMatrixFromMarker(ARMarkerInfo *nMarkerInfo, ARFloat nPatternCenter[2], ARFloat nPatternSize, ARFloat *nOpenGLMatrix)
Calculates the OpenGL transformation matrix for a specific marker info.
virtual const ARMarkerInfo & getDetectedMarker(int nWhich) const
Returns the ARMarkerInfo object for a found marker.
ARFloat executeMultiMarkerPoseEstimator(ARMarkerInfo *marker_info, int marker_num, ARMultiMarkerInfoT *config)
Calls the pose estimator set with setPoseEstimator() for multi marker tracking.
ARMultiMarkerInfoT * arMultiReadConfigFile(const char *filename)
reads a standard artoolkit multimarker config file
virtual const ARMultiMarkerInfoT * getMultiMarkerConfig() const
Returns the loaded ARMultiMarkerInfoT object.
virtual int calc(const unsigned char *nImage)
calculates the transformation matrix
int getBitsPerPixel() const
Returns the numbber of bits per pixel for the compiled-in pixel format.
void setCamera(Camera *nCamera, ARFloat nNearClip, ARFloat nFarClip)
Sets a new camera including specifying new near and far clip values.
bool isAutoThresholdActivated() const
Returns true if automatic threshold detection is enabled.
int arMultiFreeConfig(ARMultiMarkerInfoT *config)
frees a multimarker config from memory
ARToolKit::Logger specifies the interface for a logging application.
Definition: Logger.h:61
#define NULL
Definition: PocketKnife.h:38
void activateAutoThreshold(bool nEnable)
Turns automatic threshold calculation on/off.
int getNumLoadablePatterns() const
Returns the maximum number of patterns that can be loaded.
void setMarkerMode(MARKER_MODE nMarkerMode)
Activate the usage of id-based markers rather than template based markers.
int arFreePatt(int patno)
frees a pattern from memory
int arDetectMarkerLite(ARUint8 *dataPtr, int thresh, ARMarkerInfo **marker_info, int *marker_num)
marker detection without using tracking history
const ARFloat * getProjectionMatrix() const
Returns an opengl-style projection transformation matrix.
void setUndistortionMode(UNDIST_MODE nMode)
Changes the undistortion mode.
TrackerImpl implements the Tracker interface.
Definition: TrackerImpl.h:94
ARFloat arGetTransMat(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4])
calculates the transformation matrix between camera and the given marker
ARFloat rppGetTransMat(ARMarkerInfo *marker_info, ARFloat center[2], ARFloat width, ARFloat conv[3][4])
float ARFloat
Definition: config.h:60
void setLogger(ARToolKitPlus::Logger *nLogger)
sets an instance which implements the ARToolKit::Logger interface
int arLoadPatt(char *filename)
loads a pattern from a file
virtual void getDetectedMarkers(int *&nMarkerIDs)
Returns array of detected marker IDs.
ARFloat arGetTransMatCont(ARMarkerInfo *marker_info, ARFloat prev_conv[3][4], ARFloat center[2], ARFloat width, ARFloat conv[3][4])
void setBorderWidth(ARFloat nFraction)
Sets a new relative border width. ARToolKit&#39;s default value is 0.25.


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