ARX  1.2.0
The next-generation open source augmented reality toolkit.
Loading...
Searching...
No Matches
ARTracker2d.h
Go to the documentation of this file.
1/*
2 * ARTracker2d.h
3 * artoolkitX
4 *
5 * A C++ class implementing the artoolkitX 2d 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 ARTRACKER2D_H
43#define ARTRACKER2D_H
44
45#include <ARX/AR/config.h>
46#if HAVE_2D
47
48#include <ARX/ARTrackable2d.h>
49#include <ARX/ARTrackerVideo.h>
50#include <ARX/AR2/tracking.h>
52
53class ARTracker2d : public ARTrackerVideo {
54public:
55 ARTracker2d();
56 ~ARTracker2d();
57
58 ARTrackerType type() const override {
60 }
61
62 std::vector<std::string> trackableConfigurations() const override {
63 std::vector<std::string> sv;
64 sv.push_back("2d");
65 return sv;
66 }
67
68 bool initialize() override;
69
70 void setMaxMarkersToTrack(int maximumNumberOfMarkersToTrack);
71 int getMaxMarkersToTrack() const;
72
73 bool start(ARParamLT *paramLT, AR_PIXEL_FORMAT pixelFormat) override;
74 bool start(ARParamLT *paramLT0, AR_PIXEL_FORMAT pixelFormat0, ARParamLT *paramLT1, AR_PIXEL_FORMAT pixelFormat1, const ARdouble transL2R[3][4]) override;
75 bool isRunning() override;
76 bool wantsUpdate() override;
77 bool update(AR2VideoBufferT *buff) override;
78 bool update(AR2VideoBufferT *buff0, AR2VideoBufferT *buff1) override;
79 bool stop() override;
80 void terminate() override;
81
82 int newTrackable(std::vector<std::string> config) override;
83 unsigned int countTrackables() override;
84 std::shared_ptr<ARTrackable> getTrackable(int UID) override;
85 std::vector<std::shared_ptr<ARTrackable>> getAllTrackables() override;
86 bool deleteTrackable(int UID) override;
87 void deleteAllTrackables() override;
88
89 bool loadImageDatabase(std::string filename);
90 bool saveImageDatabase(std::string filename);
91
92 void setDetectorType(PlanarTracker::FeatureDetectorType detectorType);
93 PlanarTracker::FeatureDetectorType getDetectorType(void);
94 void setMinRequiredDetectedFeatures(int num);
95 int getMinRequiredDetectedFeatures(void);
96 void setHomographyEstimationRANSACThreshold(double thresh);
97 double getHomographyEstimationRANSACThreshold(void);
98
99 bool threaded(void) const;
108 void setThreaded(bool threaded);
109
110 void setTrackerVisualizationActive(bool active);
111 void *getTrackerVisualization(void);
112
113private:
114
115 AR_PIXEL_FORMAT m_pixelFormat;
116 int m_sizeX;
117 int m_sizeY;
118
119 std::vector<std::shared_ptr<ARTrackable>> m_trackables;
120 bool m_videoSourceIsStereo;
121 bool m_2DTrackerDataLoaded;
122 int m_2DTrackerDetectedImageCount;
123 std::shared_ptr<PlanarTracker> m_2DTracker;
124 // 2d data.
125 ARdouble m_transL2R[3][4];
126
127 bool m_running;
128 bool unloadTwoDData();
129 bool loadTwoDData();
130 void updateTrackablesFromTracker();
131 int m_pageCount;
132
133 bool m_threaded;
134 THREAD_HANDLE_T *m_trackingThread;
135 static void *trackingWorker(THREAD_HANDLE_T *threadHandle);
136 ARUint8 *m_trackingBuffcopy;
137};
138
139#endif // HAVE_2D
140#endif // !ARTRACKER2D_H
141
ARTrackerType
Definition ARTracker.h:51
@ TEXTURE2D_FIDUCIAL
Definition ARTracker.h:53
unsigned char ARUint8
Definition ar.h:92
double ARdouble
Definition ar.h:99
Definition ARTrackerVideo.h:49
FeatureDetectorType
Defaults to defaultDetectorType.
Definition PlanarTracker.h:96
struct _THREAD_HANDLE_T THREAD_HANDLE_T
Definition thread_sub.h:56