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
47#include <ARX/ARTrackerVideo.h>
48#include <ARX/AR/ar.h>
49
51public:
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
110
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
141
143
144 void setPatternSize(int patternSize);
145
146 int patternSize() const;
147
149
150 int patternCountMax() const;
151
152 void setMatrixModeAutoCreateNewTrackables(bool on) { m_matrixModeAutoCreateNewTrackables = on; }
153
154 bool matrixModeAutoCreateNewTrackables() const { return m_matrixModeAutoCreateNewTrackables; }
155
157 void setMatrixModeAutoCreateNewTrackablesCallback(MatrixModeAutoCreateNewTrackablesCallback_t callback) { m_matrixModeAutoCreateNewTrackablesCallback = callback; }
158 MatrixModeAutoCreateNewTrackablesCallback_t matrixModeAutoCreateNewTrackablesCallback() const { return m_matrixModeAutoCreateNewTrackablesCallback; }
159
160
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
184private:
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
ARTrackerType
Definition: ARTracker.h:51
artoolkitX core routines.
AR_MATRIX_CODE_TYPE
Values specifying the type of matrix code in use.
Definition: ar.h:320
double ARdouble
Definition: ar.h:99
AR_LABELING_THRESH_MODE
Values controlling the labeling thresholding mode.
Definition: ar.h:160
Single marker type of ARTrackable.
Definition: ARTrackableSquare.h:50
Definition: ARTrackerSquare.h:50
void setMatrixModeAutoCreateNewTrackables(bool on)
Definition: ARTrackerSquare.h:152
int newTrackable(std::vector< std::string > config) override
ARTrackable factory method.
Definition: ARTrackerSquare.cpp:510
~ARTrackerSquare()
Definition: ARTrackerSquare.cpp:72
bool wantsUpdate() override
Definition: ARTrackerSquare.cpp:368
bool matrixModeAutoCreateNewTrackables() const
Definition: ARTrackerSquare.h:154
void deleteAllTrackables() override
Definition: ARTrackerSquare.cpp:717
void setImageProcMode(int mode)
Definition: ARTrackerSquare.cpp:116
int imageProcMode() const
Definition: ARTrackerSquare.cpp:130
MatrixModeAutoCreateNewTrackablesCallback_t matrixModeAutoCreateNewTrackablesCallback() const
Definition: ARTrackerSquare.h:158
ARTrackerSquare()
Definition: ARTrackerSquare.cpp:48
unsigned int countTrackables() override
Definition: ARTrackerSquare.cpp:688
std::vector< std::string > trackableConfigurations() const override
Definition: ARTrackerSquare.h:59
void setThresholdMode(AR_LABELING_THRESH_MODE mode)
Sets the thresholding mode to use.
Definition: ARTrackerSquare.cpp:154
void setDebugMode(bool debug)
Enables or disables debug mode in the tracker.
Definition: ARTrackerSquare.cpp:98
void setPatternSize(int patternSize)
Definition: ARTrackerSquare.cpp:245
void setLabelingMode(int mode)
Sets the labeling mode to use.
Definition: ARTrackerSquare.cpp:172
void terminate() override
Definition: ARTrackerSquare.cpp:502
void setMatrixModeAutoCreateNewTrackablesCallback(MatrixModeAutoCreateNewTrackablesCallback_t callback)
Definition: ARTrackerSquare.h:157
AR_MATRIX_CODE_TYPE matrixCodeType() const
Definition: ARTrackerSquare.cpp:240
bool debugMode() const
Returns whether debug mode is currently enabled.
Definition: ARTrackerSquare.cpp:111
void setMatrixCodeType(AR_MATRIX_CODE_TYPE type)
Definition: ARTrackerSquare.cpp:227
AR_LABELING_THRESH_MODE thresholdMode() const
Returns the current thresholding mode.
Definition: ARTrackerSquare.cpp:167
void setThreshold(int thresh)
Sets the threshold value used for image binarization.
Definition: ARTrackerSquare.cpp:135
bool initialize() override
Definition: ARTrackerSquare.cpp:77
float matrixModeAutoCreateNewTrackablesDefaultWidth() const
Definition: ARTrackerSquare.h:164
int patternSize() const
Definition: ARTrackerSquare.cpp:261
std::shared_ptr< ARTrackable > getTrackable(int UID) override
Definition: ARTrackerSquare.cpp:693
static constexpr float k_matrixModeAutoCreateNewTrackablesDefaultWidth_default
Definition: ARTrackerSquare.h:161
float pattRatio() const
Definition: ARTrackerSquare.cpp:222
void setPatternDetectionMode(int mode)
Definition: ARTrackerSquare.cpp:190
void setMatrixModeAutoCreateNewTrackablesDefaultWidth(ARdouble width)
Definition: ARTrackerSquare.h:162
void setPattRatio(float ratio)
Definition: ARTrackerSquare.cpp:208
bool isRunning() override
Definition: ARTrackerSquare.cpp:88
ARTrackerType type() const override
Definition: ARTrackerSquare.h:55
int labelingMode() const
Returns the current labeling mode.
Definition: ARTrackerSquare.cpp:185
int threshold() const
Returns the current threshold value used for image binarization.
Definition: ARTrackerSquare.cpp:149
std::vector< std::shared_ptr< ARTrackable > > getAllTrackables() override
Definition: ARTrackerSquare.cpp:702
void setPatternCountMax(int patternCountMax)
Definition: ARTrackerSquare.cpp:266
int patternCountMax() const
Definition: ARTrackerSquare.cpp:282
bool updateDebugTextureRGBA32(const int videoSourceIndex, uint32_t *buffer)
Definition: ARTrackerSquare.cpp:726
void(* MatrixModeAutoCreateNewTrackablesCallback_t)(const ARTrackableSquare &trackable)
Definition: ARTrackerSquare.h:156
bool deleteTrackable(int UID) override
Removes the trackable with UID uid, if held by this tracker.
Definition: ARTrackerSquare.cpp:707
int patternDetectionMode() const
Definition: ARTrackerSquare.cpp:203
bool stop() override
Definition: ARTrackerSquare.cpp:478
Definition: ARTrackerVideo.h:49
A structure which carries information about a video frame retrieved by the video library.
Definition: ar.h:148
Structure holding state of an instance of the monocular pose estimator.
Definition: ar.h:385
Structure holding state of an instance of the stereo pose estimator.
Definition: ar.h:395
Structure holding state of an instance of the square marker tracker.
Definition: ar.h:342
Structure holding camera parameters, in lookup table form.
Definition: param.h:151
A structure which holds descriptions of trained patterns for template matching.
Definition: ar.h:268