Ocean
devices/pattern/PatternTracker6DOF.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_DEVICES_PATTERN_TRACKER_6DOF_H
9 #define META_OCEAN_DEVICES_PATTERN_TRACKER_6DOF_H
10 
13 
14 #include "ocean/base/Thread.h"
15 
20 
22 
24 
25 namespace Ocean
26 {
27 
28 namespace Devices
29 {
30 
31 namespace Pattern
32 {
33 
34 /**
35  * This class implements a Pattern feature-based tracker.
36  * @ingroup devicespattern
37  */
38 class OCEAN_DEVICES_PATTERN_EXPORT PatternTracker6DOF :
39  virtual public PatternDevice,
40  virtual public Tracker6DOF,
41  virtual public ObjectTracker,
42  virtual public VisualTracker,
43  protected Thread
44 {
45  friend class PatternFactory;
46 
47  public:
48 
49  /**
50  * Adds a new tracking pattern.
51  * For this pattern feature based tracker the pattern must be the url of an image.
52  * @see ObjectTracker::registerObject().
53  */
54  ObjectId registerObject(const std::string& description, const Vector3& dimension) override;
55 
56  /**
57  * Returns whether this device is active.
58  * @see Devices::isStarted().
59  */
60  bool isStarted() const override;
61 
62  /**
63  * Starts the device.
64  * @see Device::start().
65  */
66  bool start() override;
67 
68  /**
69  * Stops the device.
70  * @see Device::stop().
71  */
72  bool stop() override;
73 
74  /**
75  * Returns whether a specific object is currently actively tracked by this tracker.
76  * @see Tracker::isObjectTracked().
77  */
78  bool isObjectTracked(const ObjectId& objectId) const override;
79 
80  /**
81  * Sets a parameter for this tracker.
82  * Supprted parameters 'noFrameToFrameTracking', 'noDownsamplingOnAndroid'.
83  * @see Device::setParameter().
84  */
85  bool setParameter(const std::string& parameter, const Value& value) override;
86 
87  /**
88  * Returns a parameter of this device.
89  * Supprted parameters 'noFrameToFrameTracking', 'noDownsamplingOnAndroid'.
90  * @see Device::parameter().
91  */
92  bool parameter(const std::string& parameter, Value& value) override;
93 
94  /**
95  * Returns the name of this tracker.
96  * @return Tracker name
97  */
98  static inline std::string deviceNamePatternTracker6DOF();
99 
100  /**
101  * Returns the type of this tracker.
102  * @return Tracker type
103  */
104  static inline DeviceType deviceTypePatternTracker6DOF();
105 
106  private:
107 
108  /**
109  * Creates a new Pattern feature based 6DOF tracker object.
110  */
112 
113  /**
114  * Destructs an Pattern feature based 6DOF tracker object.
115  */
117 
118  /**
119  * Ensures that the tracker exists, if the tracker does not yet exist, it will be created.
120  */
122 
123  /**
124  * Thread function.
125  * @see Thread::threadRun().
126  */
127  void threadRun() override;
128 
129  private:
130 
131  /// Frame timestamp.
133 
134  /// Holds the 6DOF tracker object.
136 
137  /// Set holding all visible marker from the most recent frame.
139 
140  /// The 3DOF orientation tracker which is used to support the tracker.
142 
143  /// The mapper between internal and external object ids.
145 
146  /// True, to skip frame-to-frame tracking.
147  bool noFrameToFrameTracking_ = false;
148 
149  /// True, to avoid downsampling the input image on Android devices.
150  bool noDownsamplingOnAndroid_ = false;
151 };
152 
154 {
155  return std::string("Pattern 6DOF Tracker");
156 }
157 
159 {
161 }
162 
163 }
164 
165 }
166 
167 }
168 
169 #endif // META_OCEAN_DEVICES_PATTERN_TRACKER_6DOF_H
Definition of a class holding the major and minor device type.
Definition: devices/Device.h:62
This class implements a helper class to simplify the mapping between internal object ids (of the actu...
Definition: Measurement.h:239
unsigned int ObjectId
Definition of an object id.
Definition: Measurement.h:46
std::unordered_set< ObjectId > ObjectIdSet
Definition of an unordered set holding object ids.
Definition: Measurement.h:56
This class is the base class for all tracker allowing to track an object or location.
Definition: ObjectTracker.h:38
This class implements a base class for all devices of the Pattern library.
Definition: PatternDevice.h:29
This class implements a device factory for the Pattern feature based tracking system.
Definition: PatternFactory.h:29
This class implements a Pattern feature-based tracker.
Definition: devices/pattern/PatternTracker6DOF.h:44
bool stop() override
Stops the device.
void ensureTrackerExists()
Ensures that the tracker exists, if the tracker does not yet exist, it will be created.
OrientationTracker3DOFRef orientationTracker3DOF_
The 3DOF orientation tracker which is used to support the tracker.
Definition: devices/pattern/PatternTracker6DOF.h:141
bool start() override
Starts the device.
Tracking::VisualTrackerRef visualTracker_
Holds the 6DOF tracker object.
Definition: devices/pattern/PatternTracker6DOF.h:135
bool isStarted() const override
Returns whether this device is active.
static DeviceType deviceTypePatternTracker6DOF()
Returns the type of this tracker.
Definition: devices/pattern/PatternTracker6DOF.h:158
ObjectIdSet visiblePatterns_
Set holding all visible marker from the most recent frame.
Definition: devices/pattern/PatternTracker6DOF.h:138
void threadRun() override
Thread function.
static std::string deviceNamePatternTracker6DOF()
Returns the name of this tracker.
Definition: devices/pattern/PatternTracker6DOF.h:153
bool isObjectTracked(const ObjectId &objectId) const override
Returns whether a specific object is currently actively tracked by this tracker.
ObjectMapper< unsigned int > objectIdMapper_
The mapper between internal and external object ids.
Definition: devices/pattern/PatternTracker6DOF.h:144
~PatternTracker6DOF() override
Destructs an Pattern feature based 6DOF tracker object.
Timestamp frameTimestamp_
Frame timestamp.
Definition: devices/pattern/PatternTracker6DOF.h:132
bool setParameter(const std::string &parameter, const Value &value) override
Sets a parameter for this tracker.
bool parameter(const std::string &parameter, Value &value) override
Returns a parameter of this device.
ObjectId registerObject(const std::string &description, const Vector3 &dimension) override
Adds a new tracking pattern.
PatternTracker6DOF()
Creates a new Pattern feature based 6DOF tracker object.
This class implements the base for all 6DOF trackers.
Definition: Tracker6DOF.h:39
static DeviceType deviceTypeTracker6DOF()
Definition of this device type.
Definition: Tracker6DOF.h:100
@ TRACKER_VISUAL
Tracker using a visual input for their measurements.
Definition: devices/Tracker.h:62
@ TRACKER_OBJECT
Tracker allowing to register tracking objects at runtime.
Definition: devices/Tracker.h:64
This class is the base class for all tracker using visual input to create the tracking results.
Definition: devices/VisualTracker.h:41
This class implements a thread.
Definition: Thread.h:115
This class implements a timestamp.
Definition: Timestamp.h:36
This class implements a type independent value.
Definition: Value.h:23
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15