Ocean
AKRoomPlanTracker6DOF.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_ROOM_PLAN_TRACKER_6_DOF_H
9 #define META_OCEAN_DEVICES_ARKIT_AK_ROOM_PLAN_TRACKER_6_DOF_H
10 
12 
15 
17 
19 
20 namespace Ocean
21 {
22 
23 namespace Devices
24 {
25 
26 namespace ARKit
27 {
28 
29 /**
30  * This class implements the 6DOF RoomPlan tracker.
31  * @ingroup devicesarkit
32  */
33 class OCEAN_DEVICES_ARKIT_EXPORT AKRoomPlanTracker6DOF :
34  virtual public AKRoomPlanTracker6DOFBase,
35  virtual public SceneTracker6DOF,
36  virtual public VisualTracker
37 {
38  friend class AKFactory;
39 
40  public:
41 
42  /**
43  * Starts the device.
44  * @see Device::start().
45  */
46  bool start() override;
47 
48  /**
49  * Pauses the device.
50  * @see Device::pause().
51  */
52  bool pause() override;
53 
54  /**
55  * Stops the device.
56  * @see Device::stop().
57  */
58  bool stop() override;
59 
60  /**
61  * Sets the multi-view visual input of this tracker.
62  * @see VisualTracker::setInput().
63  */
64  void setInput(Media::FrameMediumRefs&& frameMediums) override;
65 
66  /**
67  * Returns whether a specific object is currently actively tracked by this tracker.
68  * @see Tracker::isObjectTracked().
69  */
70  bool isObjectTracked(const ObjectId& objectId) const override;
71 
72  /**
73  * Returns the name of the owner library.
74  * @see Device::library().
75  */
76  const std::string& library() const override;
77 
78  /**
79  * Returns the name of this tracker.
80  * @return The trackers's name
81  */
82  static inline std::string deviceNameAKRoomPlanTracker6DOF();
83 
84  /**
85  * Returns the device type of this tracker.
86  * @return The tracker's device type
87  */
88  static inline DeviceType deviceTypeAKRoomPlanTracker6DOF();
89 
90  /**
91  * Returns whether the tracker is supported on the platform.
92  * @return True, if so
93  */
94  static bool isSupported();
95 
96  protected:
97 
98  /**
99  * Creates a new 6DOF room plan tracker.
100  */
102 
103  /**
104  * Destructs this 6DOF tracker.
105  */
107 
108  /**
109  * Event function for a new 6DOF pose.
110  * @param world_T_camera The transformation between camera and world, invalid if unknown/lost
111  * @param timestamp The timestamp of the new transformation
112  * @param arFrame The current ARFRame object containing additional data for the sample, must be valid
113  */
114  API_AVAILABLE(ios(11.0))
115  void onNewSample(const HomogenousMatrix4& world_T_camera, const Timestamp& timestamp, ARFrame* arFrame) override;
116 
117  /**
118  * Event function that the capture session has started.
119  */
120  void onCaptureSessionStarted() override;
121 
122  /**
123  * Event function for added room objects.
124  * @param planarRoomObjects The new planar objects
125  * @param volumetricRoomObjects The new volumetric objects
126  */
127  void onCaptureSessionAdded(const SharedPlanarRoomObjects& planarRoomObjects, const SharedVolumetricRoomObjects& volumetricRoomObjects) override;
128 
129  /**
130  * Event function for removed room objects.
131  * @param planarRoomObjects The removed planar objects
132  * @param volumetricRoomObjects The removed volumetric objects
133  */
134  void onCaptureSessionRemoved(const SharedPlanarRoomObjects& planarRoomObjects, const SharedVolumetricRoomObjects& volumetricRoomObjects) override;
135 
136  /**
137  * Event function for changed room objects.
138  * @param planarRoomObjects The changed planar objects
139  * @param volumetricRoomObjects The changed volumetric objects
140  */
141  void onCaptureSessionChanged(const SharedPlanarRoomObjects& planarRoomObjects, const SharedVolumetricRoomObjects& volumetricRoomObjects) override;
142 
143  /**
144  * Event function for updated room objects.
145  * @param planarRoomObjects The updated planar objects
146  * @param volumetricRoomObjects The updated volumetric objects
147  */
148  void onCaptureSessionUpdated(const SharedPlanarRoomObjects& planarRoomObjects, const SharedVolumetricRoomObjects& volumetricRoomObjects) override;
149 
150  /**
151  * Event function for instructions.
152  * @param instructionValue The instruction
153  */
154  void onCaptureSessionInstruction(const InstructionValue instructionValue) override;
155 
156  /**
157  * Event function that the capture session has stopped.
158  */
159  void onCaptureSessionStopped() override;
160 
161  protected:
162 
163  /// The unique id for the world object.
164  ObjectId worldObjectId_ = invalidObjectId();
165 
166  /// True, if the tracker has been started.
167  bool isStarted_ = false;
168 
169  /// True, if the world object is currently tracked.
170  bool worldIsTracked_ = false;
171 
172  /// The Objc wrapper of the actual RoomPlan tracker.
173  AKRoomPlanTracker6DOF_Objc* akRoomPlanTracker_ = nullptr;
174 
175  /// The latest room objects.
176  SceneElementRoom::RoomObjectMap roomObjectMap_;
177 
178  /// The identifiers of all added room objects.
179  SceneElementRoom::RoomObjectIdentifierSet addedRoomObjects_;
180 
181  /// The identifiers of all removed room objects.
182  SceneElementRoom::RoomObjectIdentifierSet removedRoomObjects_;
183 
184  /// The identifiers of all changed room objects.
185  SceneElementRoom::RoomObjectIdentifierSet changedRoomObjects_;
186 
187  /// The identifiers of all updated room objects.
188  SceneElementRoom::RoomObjectIdentifierSet updatedRoomObjects_;
189 
190  /// The latest instructions.
191  InstructionValue instructionValue_ = IV_UNKNOWN;
192 };
193 
194 inline std::string AKRoomPlanTracker6DOF::deviceNameAKRoomPlanTracker6DOF()
195 {
196  return std::string("ARKit 6DOF Room Plan Tracker");
197 }
198 
200 {
201  return DeviceType(deviceTypeTracker6DOF(), TRACKER_VISUAL);
202 }
203 
204 }
205 
206 }
207 
208 }
209 
210 #endif // META_OCEAN_DEVICES_ARKIT_AK_ROOM_PLAN_TRACKER_6_DOF_H
This class implements a device factory for the ARKit tracking library.
Definition: AKFactory.h:32
This class implements the base class for the 6DOF RoomPlan tracker.
Definition: AKRoomPlanTracker6DOFBase.h:35
SceneTracker6DOF::SceneElementRoom::SharedVolumetricRoomObjects SharedVolumetricRoomObjects
Re-definition of SharedVolumetricRoomObjects.
Definition: AKRoomPlanTracker6DOFBase.h:87
SceneTracker6DOF::SceneElementRoom::SharedPlanarRoomObjects SharedPlanarRoomObjects
Re-definition of SharedPlanarRoomObjects.
Definition: AKRoomPlanTracker6DOFBase.h:82
InstructionValue
Definition of individual instruction values.
Definition: AKRoomPlanTracker6DOFBase.h:42
This class implements the 6DOF RoomPlan tracker.
Definition: AKRoomPlanTracker6DOF.h:37
bool stop() override
Stops the device.
bool pause() override
Pauses the device.
~AKRoomPlanTracker6DOF() override
Destructs this 6DOF tracker.
const std::string & library() const override
Returns the name of the owner library.
static DeviceType deviceTypeAKRoomPlanTracker6DOF()
Returns the device type of this tracker.
Definition: AKRoomPlanTracker6DOF.h:199
static bool isSupported()
Returns whether the tracker is supported on the platform.
bool isObjectTracked(const ObjectId &objectId) const override
Returns whether a specific object is currently actively tracked by this tracker.
void setInput(Media::FrameMediumRefs &&frameMediums) override
Sets the multi-view visual input of this tracker.
API_AVAILABLE(ios(11.0)) void onNewSample(const HomogenousMatrix4 &world_T_camera
Event function for a new 6DOF pose.
AKRoomPlanTracker6DOF()
Creates a new 6DOF room plan tracker.
bool start() override
Starts the device.
Definition of a class holding the major and minor device type.
Definition: devices/Device.h:62
unsigned int ObjectId
Definition of an object id.
Definition: Measurement.h:46
This class implements a scene element holding room objects.
Definition: SceneTracker6DOF.h:527
This class implements the base for all 6-DOF scene trackers.
Definition: SceneTracker6DOF.h:42
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 timestamp.
Definition: Timestamp.h:36
std::vector< FrameMediumRef > FrameMediumRefs
Definition of a vector holding frame medium reference objects.
Definition: FrameMedium.h:46
const ObjectId invalidObjectId
Definition of an invalid object id.
Definition: rendering/Rendering.h:65
This class implements the Objc wrapper for the room plan tracker.
Definition: AKRoomPlanTracker6DOF_Objc.h:26
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15