| ARX 1.0 The next-generation open source augmented reality toolkit.

Loading...
Searching...
No Matches
ARTrackerSquare.h
Go to the documentation of this file.
1/*
2 * ARTrackerSquare.h
3 * artoolkitX
4 *
5 * A C++ class implementing the artoolkitX square fiducial marker tracker.
6 *
7 * This file is part of artoolkitX.
8 *
9 * artoolkitX is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * artoolkitX is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with artoolkitX. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * As a special exception, the copyright holders of this library give you
23 * permission to link this library with independent modules to produce an
24 * executable, regardless of the license terms of these independent modules, and to
25 * copy and distribute the resulting executable under terms of your choice,
26 * provided that you also meet, for each linked independent module, the terms and
27 * conditions of the license of that module. An independent module is a module
28 * which is neither derived from nor based on this library. If you modify this
29 * library, you may extend this exception to your version of the library, but you
30 * are not obligated to do so. If you do not wish to do so, delete this exception
31 * statement from your version.
32 *
33 * Copyright 2018 Realmax, Inc.
34 * Copyright 2015 Daqri, LLC.
35 * Copyright 2010-2015 ARToolworks, Inc.
36 *
37 * Author(s): Philip Lamb, Julian Looser.
38 *
39 */
40
41
42#ifndef ARTRACKERSQUARE_H
43#define ARTRACKERSQUARE_H
44
45#include <ARX/ARTrackableSquare.h>
46#include <ARX/ARTrackableMultiSquare.h>
47#include <ARX/ARTrackerVideo.h>
48#include <ARX/AR/ar.h>
49
50 class ARTrackerSquare : public ARTrackerVideo {
51 public:
52 ARTrackerSquare();
53 ~ARTrackerSquare();
54
55 ARTrackerType type() const override {
56 return ARTrackerType::SQUARE_FIDUCIAL;
57 }
58
59 std::vector<std::string> trackableConfigurations() const override {
60 std::vector<std::string> sv;
61 sv.push_back("single");
62 sv.push_back("single_barcode");
63 sv.push_back("single_buffer");
64 sv.push_back("multi");
65 return sv;
66 }
67
68 bool initialize() override;
69
77 void setDebugMode(bool debug);
78
84 bool debugMode() const;
85
86 void setImageProcMode(int mode);
87
88 int imageProcMode() const;
89
95 void setThreshold(int thresh);
96
102 int threshold() const;
103
109 void setThresholdMode(AR_LABELING_THRESH_MODE mode);
110
116 AR_LABELING_THRESH_MODE thresholdMode() const;
117
123 void setLabelingMode(int mode);
124
130 int labelingMode() const;
131
132 void setPatternDetectionMode(int mode);
133
134 int patternDetectionMode() const;
135
136 void setPattRatio(float ratio);
137
138 float pattRatio() const;
139
140 void setMatrixCodeType(AR_MATRIX_CODE_TYPE type);
141
142 AR_MATRIX_CODE_TYPE matrixCodeType() const;
143
144 void setPatternSize(int patternSize);
145
146 int patternSize() const;
147
148 void setPatternCountMax(int patternCountMax);
149
150 int patternCountMax() const;
151
152 void setMatrixModeAutoCreateNewTrackables(bool on) { m_matrixModeAutoCreateNewTrackables = on; }
153
154 bool matrixModeAutoCreateNewTrackables() const { return m_matrixModeAutoCreateNewTrackables; }
155
156 typedef void (*MatrixModeAutoCreateNewTrackablesCallback_t)(const ARTrackableSquare& trackable);
157 void setMatrixModeAutoCreateNewTrackablesCallback(MatrixModeAutoCreateNewTrackablesCallback_t callback) { m_matrixModeAutoCreateNewTrackablesCallback = callback; }
158 MatrixModeAutoCreateNewTrackablesCallback_t matrixModeAutoCreateNewTrackablesCallback() const { return m_matrixModeAutoCreateNewTrackablesCallback; }
159
160
161 static constexpr float k_matrixModeAutoCreateNewTrackablesDefaultWidth_default = 80.0f;
162 void setMatrixModeAutoCreateNewTrackablesDefaultWidth(ARdouble width) { m_matrixModeAutoCreateNewTrackablesDefaultWidth = width; }
163
164 float matrixModeAutoCreateNewTrackablesDefaultWidth() const { return m_matrixModeAutoCreateNewTrackablesDefaultWidth; }
165
166 bool start(ARParamLT *paramLT, AR_PIXEL_FORMAT pixelFormat) override;
167 bool start(ARParamLT *paramLT0, AR_PIXEL_FORMAT pixelFormat0, ARParamLT *paramLT1, AR_PIXEL_FORMAT pixelFormat1, const ARdouble transL2R[3][4]) override;
168 bool isRunning() override;
169 bool wantsUpdate() override;
170 bool update(AR2VideoBufferT *buff) override;
171 bool update(AR2VideoBufferT *buff0, AR2VideoBufferT *buff1) override;
172 bool stop() override;
173 void terminate() override;
174
175 int newTrackable(std::vector<std::string> config) override;
176 unsigned int countTrackables() override;
177 std::shared_ptr<ARTrackable> getTrackable(int UID) override;
178 std::vector<std::shared_ptr<ARTrackable>> getAllTrackables() override;
179 bool deleteTrackable(int UID) override;
180 void deleteAllTrackables() override;
181
182 bool updateDebugTextureRGBA32(const int videoSourceIndex, uint32_t* buffer);
183
184 private:
185 std::vector<std::shared_ptr<ARTrackable>> m_trackables;
186 int m_threshold;
187 AR_LABELING_THRESH_MODE m_thresholdMode;
188 int m_imageProcMode;
189 int m_labelingMode;
190 ARdouble m_pattRatio;
191 int m_patternDetectionMode;
192 AR_MATRIX_CODE_TYPE m_matrixCodeType;
193 bool m_debugMode;
194 int m_patternSize;
195 int m_patternCountMax;
196 bool m_matrixModeAutoCreateNewTrackables;
197 float m_matrixModeAutoCreateNewTrackablesDefaultWidth;
198 MatrixModeAutoCreateNewTrackablesCallback_t m_matrixModeAutoCreateNewTrackablesCallback;
199
200 ARHandle *m_arHandle0;
201 ARHandle *m_arHandle1;
202 ARPattHandle *m_arPattHandle;
203 AR3DHandle *m_ar3DHandle;
204 ARdouble m_transL2R[3][4];
205 AR3DStereoHandle *m_ar3DStereoHandle;
206};
207
208#endif // !ARTRACKERSQUARE_H
ARTrackableMultiSquare.h
ARTrackableSquare.h
ARTrackerType
ARTrackerType
Definition: ARTracker.h:51
ARTrackerVideo.h
ar.h
artoolkitX core routines.
AR_MATRIX_CODE_TYPE
AR_MATRIX_CODE_TYPE
Values specifying the type of matrix code in use.
Definition: ar.h:320
ARdouble
double ARdouble
Definition: ar.h:99
AR_LABELING_THRESH_MODE
AR_LABELING_THRESH_MODE
Values controlling the labeling thresholding mode.
Definition: ar.h:160
ARTrackableSquare
Single marker type of ARTrackable.
Definition: ARTrackableSquare.h:50
ARTrackerSquare
Definition: ARTrackerSquare.h:50
ARTrackerSquare::setMatrixModeAutoCreateNewTrackables
void setMatrixModeAutoCreateNewTrackables(bool on)
Definition: ARTrackerSquare.h:152
ARTrackerSquare::newTrackable
int newTrackable(std::vector< std::string > config) override
ARTrackable factory method.
Definition: ARTrackerSquare.cpp:510
ARTrackerSquare::~ARTrackerSquare
~ARTrackerSquare()
Definition: ARTrackerSquare.cpp:72
ARTrackerSquare::wantsUpdate
bool wantsUpdate() override
Definition: ARTrackerSquare.cpp:368
ARTrackerSquare::matrixModeAutoCreateNewTrackables
bool matrixModeAutoCreateNewTrackables() const
Definition: ARTrackerSquare.h:154
ARTrackerSquare::deleteAllTrackables
void deleteAllTrackables() override
Definition: ARTrackerSquare.cpp:717
ARTrackerSquare::setImageProcMode
void setImageProcMode(int mode)
Definition: ARTrackerSquare.cpp:116
ARTrackerSquare::imageProcMode
int imageProcMode() const
Definition: ARTrackerSquare.cpp:130
ARTrackerSquare::matrixModeAutoCreateNewTrackablesCallback
MatrixModeAutoCreateNewTrackablesCallback_t matrixModeAutoCreateNewTrackablesCallback() const
Definition: ARTrackerSquare.h:158
ARTrackerSquare::ARTrackerSquare
ARTrackerSquare()
Definition: ARTrackerSquare.cpp:48
ARTrackerSquare::countTrackables
unsigned int countTrackables() override
Definition: ARTrackerSquare.cpp:688
ARTrackerSquare::trackableConfigurations
std::vector< std::string > trackableConfigurations() const override
Definition: ARTrackerSquare.h:59
ARTrackerSquare::setThresholdMode
void setThresholdMode(AR_LABELING_THRESH_MODE mode)
Sets the thresholding mode to use.
Definition: ARTrackerSquare.cpp:154
ARTrackerSquare::setDebugMode
void setDebugMode(bool debug)
Enables or disables debug mode in the tracker.
Definition: ARTrackerSquare.cpp:98
ARTrackerSquare::setPatternSize
void setPatternSize(int patternSize)
Definition: ARTrackerSquare.cpp:245
ARTrackerSquare::setLabelingMode
void setLabelingMode(int mode)
Sets the labeling mode to use.
Definition: ARTrackerSquare.cpp:172
ARTrackerSquare::terminate
void terminate() override
Definition: ARTrackerSquare.cpp:502
ARTrackerSquare::setMatrixModeAutoCreateNewTrackablesCallback
void setMatrixModeAutoCreateNewTrackablesCallback(MatrixModeAutoCreateNewTrackablesCallback_t callback)
Definition: ARTrackerSquare.h:157
ARTrackerSquare::matrixCodeType
AR_MATRIX_CODE_TYPE matrixCodeType() const
Definition: ARTrackerSquare.cpp:240
ARTrackerSquare::debugMode
bool debugMode() const
Returns whether debug mode is currently enabled.
Definition: ARTrackerSquare.cpp:111
ARTrackerSquare::setMatrixCodeType
void setMatrixCodeType(AR_MATRIX_CODE_TYPE type)
Definition: ARTrackerSquare.cpp:227
ARTrackerSquare::thresholdMode
AR_LABELING_THRESH_MODE thresholdMode() const
Returns the current thresholding mode.
Definition: ARTrackerSquare.cpp:167
ARTrackerSquare::setThreshold
void setThreshold(int thresh)
Sets the threshold value used for image binarization.
Definition: ARTrackerSquare.cpp:135
ARTrackerSquare::initialize
bool initialize() override
Definition: ARTrackerSquare.cpp:77
ARTrackerSquare::matrixModeAutoCreateNewTrackablesDefaultWidth
float matrixModeAutoCreateNewTrackablesDefaultWidth() const
Definition: ARTrackerSquare.h:164
ARTrackerSquare::patternSize
int patternSize() const
Definition: ARTrackerSquare.cpp:261
ARTrackerSquare::getTrackable
std::shared_ptr< ARTrackable > getTrackable(int UID) override
Definition: ARTrackerSquare.cpp:693
ARTrackerSquare::k_matrixModeAutoCreateNewTrackablesDefaultWidth_default
static constexpr float k_matrixModeAutoCreateNewTrackablesDefaultWidth_default
Definition: ARTrackerSquare.h:161
ARTrackerSquare::pattRatio
float pattRatio() const
Definition: ARTrackerSquare.cpp:222
ARTrackerSquare::setPatternDetectionMode
void setPatternDetectionMode(int mode)
Definition: ARTrackerSquare.cpp:190
ARTrackerSquare::setMatrixModeAutoCreateNewTrackablesDefaultWidth
void setMatrixModeAutoCreateNewTrackablesDefaultWidth(ARdouble width)
Definition: ARTrackerSquare.h:162
ARTrackerSquare::setPattRatio
void setPattRatio(float ratio)
Definition: ARTrackerSquare.cpp:208
ARTrackerSquare::isRunning
bool isRunning() override
Definition: ARTrackerSquare.cpp:88
ARTrackerSquare::type
ARTrackerType type() const override
Definition: ARTrackerSquare.h:55
ARTrackerSquare::labelingMode
int labelingMode() const
Returns the current labeling mode.
Definition: ARTrackerSquare.cpp:185
ARTrackerSquare::threshold
int threshold() const
Returns the current threshold value used for image binarization.
Definition: ARTrackerSquare.cpp:149
ARTrackerSquare::getAllTrackables
std::vector< std::shared_ptr< ARTrackable > > getAllTrackables() override
Definition: ARTrackerSquare.cpp:702
ARTrackerSquare::setPatternCountMax
void setPatternCountMax(int patternCountMax)
Definition: ARTrackerSquare.cpp:266
ARTrackerSquare::patternCountMax
int patternCountMax() const
Definition: ARTrackerSquare.cpp:282
ARTrackerSquare::updateDebugTextureRGBA32
bool updateDebugTextureRGBA32(const int videoSourceIndex, uint32_t *buffer)
Definition: ARTrackerSquare.cpp:726
ARTrackerSquare::MatrixModeAutoCreateNewTrackablesCallback_t
void(* MatrixModeAutoCreateNewTrackablesCallback_t)(const ARTrackableSquare &trackable)
Definition: ARTrackerSquare.h:156
ARTrackerSquare::deleteTrackable
bool deleteTrackable(int UID) override
Removes the trackable with UID uid, if held by this tracker.
Definition: ARTrackerSquare.cpp:707
ARTrackerSquare::patternDetectionMode
int patternDetectionMode() const
Definition: ARTrackerSquare.cpp:203
ARTrackerSquare::stop
bool stop() override
Definition: ARTrackerSquare.cpp:478
ARTrackerVideo
Definition: ARTrackerVideo.h:49
AR2VideoBufferT
A structure which carries information about a video frame retrieved by the video library.
Definition: ar.h:148
AR3DHandle
Structure holding state of an instance of the monocular pose estimator.
Definition: ar.h:385
AR3DStereoHandle
Structure holding state of an instance of the stereo pose estimator.
Definition: ar.h:395
ARHandle
Structure holding state of an instance of the square marker tracker.
Definition: ar.h:342
ARParamLT
Structure holding camera parameters, in lookup table form.
Definition: param.h:151
ARPattHandle
A structure which holds descriptions of trained patterns for template matching.
Definition: ar.h:268