Ocean
Loading...
Searching...
No Matches
AKPlaneTracker6DOF.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_ARKIT_AK_PLANE_TRACKER_6_DOF_H
9#define META_OCEAN_DEVICES_ARKIT_AK_PLANE_TRACKER_6_DOF_H
10
13
16
17namespace Ocean
18{
19
20namespace Devices
21{
22
23namespace ARKit
24{
25
26/**
27 * This class implements a 6DOF plane tracker based on ARKit.
28 * @ingroup devicesarkit
29 */
30class OCEAN_DEVICES_ARKIT_EXPORT AKPlaneTracker6DOF :
31 virtual public AKDevice,
32 virtual public SceneTracker6DOF,
33 virtual public VisualTracker
34{
35 friend class AKFactory;
36
37 protected:
38
39 /**
40 * Definition of an unordered map mapping anchor identifier strings to unique ids.
41 */
42 using IdentifierMap = std::unordered_map<std::string, Index32>;
43
44 public:
45
46 /**
47 * Starts the device.
48 * @see Device::start().
49 */
50 bool start() override;
51
52 /**
53 * Pauses the device.
54 * @see Device::pause().
55 */
56 bool pause() override;
57
58 /**
59 * Stops the device.
60 * @see Device::stop().
61 */
62 bool stop() override;
63
64 /**
65 * Sets the multi-view visual input of this tracker.
66 * @see VisualTracker::setInput().
67 */
68 void setInput(Media::FrameMediumRefs&& frameMediums) override;
69
70 /**
71 * Returns whether a specific object is currently actively tracked by this tracker.
72 * @see Tracker::isObjectTracked().
73 */
74 bool isObjectTracked(const ObjectId& objectId) const override;
75
76 /**
77 * Event function for a new 6DOF pose.
78 * @param world_T_camera The transformation between camera and world, invalid if unknown/lost
79 * @param timestamp The timestamp of the new transformation
80 * @param arFrame The current ARFRame object containing additional data for the sample, must be valid
81 */
82 API_AVAILABLE(ios(11.3))
83 void onNewSample(const HomogenousMatrix4& world_T_camera, const Timestamp& timestamp, ARFrame* arFrame);
84
85 /**
86 * Event function for a new 6DOF pose.
87 * @param world_T_camera The transformation between camera and world, invalid if unknown/lost
88 * @param sceneElement The scene element which is part of the sample, nullptr if no scene element is known
89 * @param timestamp The timestamp of the new transformation
90 * @param metadata The metadata of the sample
91 */
92 void onNewSample(const HomogenousMatrix4& world_T_camera, SharedSceneElement&& sceneElement, const Timestamp& timestamp, Metadata&& metadata);
93
94 /**
95 * Returns the name of this tracker.
96 * @return The trackers's name
97 */
98 static inline std::string deviceNameAKPlaneTracker6DOF();
99
100 /**
101 * Returns the device type of this tracker.
102 * @return The tracker's device type
103 */
105
106 protected:
107
108 /**
109 * Creates a new 6DOF plane tracker.
110 */
112
113 /**
114 * Destructs this 6DOF tracker.
115 */
117
118 protected:
119
120 /// The unique id for the world object.
122
123 /// True, if the tracker has been started.
124 bool isStarted_ = false;
125
126 /// True, if the world object is currently tracked.
127 bool worldIsTracked_ = false;
128
129 /// The map mapping unique plane identifier strings to plane ids.
131
132 /// The counter for unique plane ids.
133 unsigned int planeIdCounter_ = 0u;
134};
135
137{
138 return std::string("ARKit 6DOF Plane Tracker");
139}
140
145
146}
147
148}
149
150}
151
152#endif // META_OCEAN_DEVICES_ARKIT_AK_PLANE_TRACKER_6_DOF_H
AKDevice(const TrackerCapabilities trackerCapabilities, const std::string &name, const DeviceType type)
Translates the value of an ARGeoTrackingState to a readable string.
unsigned int planeIdCounter_
The counter for unique plane ids.
Definition AKPlaneTracker6DOF.h:133
bool isObjectTracked(const ObjectId &objectId) const override
Returns whether a specific object is currently actively tracked by this tracker.
bool stop() override
Stops the device.
static std::string deviceNameAKPlaneTracker6DOF()
Returns the name of this tracker.
Definition AKPlaneTracker6DOF.h:136
void onNewSample(const HomogenousMatrix4 &world_T_camera, SharedSceneElement &&sceneElement, const Timestamp &timestamp, Metadata &&metadata)
Event function for a new 6DOF pose.
const Timestamp & timestamp
Definition AKPlaneTracker6DOF.h:83
bool pause() override
Pauses the device.
const Timestamp ARFrame * arFrame
Definition AKPlaneTracker6DOF.h:83
bool isStarted_
True, if the tracker has been started.
Definition AKPlaneTracker6DOF.h:124
std::unordered_map< std::string, Index32 > IdentifierMap
Definition of an unordered map mapping anchor identifier strings to unique ids.
Definition AKPlaneTracker6DOF.h:42
ObjectId worldObjectId_
The unique id for the world object.
Definition AKPlaneTracker6DOF.h:121
API_AVAILABLE(ios(11.3)) void onNewSample(const HomogenousMatrix4 &world_T_camera
Event function for a new 6DOF pose.
bool worldIsTracked_
True, if the world object is currently tracked.
Definition AKPlaneTracker6DOF.h:127
bool start() override
Starts the device.
AKPlaneTracker6DOF()
Creates a new 6DOF plane tracker.
static DeviceType deviceTypeAKPlaneTracker6DOF()
Returns the device type of this tracker.
Definition AKPlaneTracker6DOF.h:141
void setInput(Media::FrameMediumRefs &&frameMediums) override
Sets the multi-view visual input of this tracker.
IdentifierMap identifierMap_
The map mapping unique plane identifier strings to plane ids.
Definition AKPlaneTracker6DOF.h:130
friend class AKFactory
Definition AKPlaneTracker6DOF.h:35
Definition of a class holding the major and minor device type.
Definition devices/Device.h:62
ObjectId objectId(const std::string &description) const
Returns the object id for an object description.
static constexpr ObjectId invalidObjectId()
Returns an invalid object id.
Definition Measurement.h:631
uint32_t ObjectId
Definition of an object id.
Definition Measurement.h:47
std::unordered_map< std::string, Value > Metadata
Definition of an unordered map mapping keys to values.
Definition Measurement.h:62
SceneTracker6DOF(const std::string &name)
Creates a new 6-DOF scene tracker object.
std::shared_ptr< SceneElement > SharedSceneElement
Definition of a shared pointer holding a scene element.
Definition SceneTracker6DOF.h:910
static DeviceType deviceTypeTracker6DOF()
Definition of this device type.
Definition Tracker6DOF.h:106
@ TRACKER_VISUAL
Tracker using a visual input for their measurements.
Definition devices/Tracker.h:64
@ SCENE_TRACKER_6DOF
6DOF scene tracker.
Definition devices/Tracker.h:56
VisualTracker(const std::string &name, const DeviceType type)
Creates a new visual tracker object.
This class implements a timestamp.
Definition Timestamp.h:64
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
std::vector< FrameMediumRef > FrameMediumRefs
Definition of a vector holding frame medium reference objects.
Definition FrameMedium.h:46
Namespace of the Devices ARKit library.
Definition AKDepthTracker6DOF.h:24
Namespace of the Devices library.
Definition AccelerationSensor3DOF.h:24
The namespace covering the entire Ocean framework.
Definition Accessor.h:15