Ocean
Loading...
Searching...
No Matches
OfflinePose.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_TRACKING_OFFLINE_OFFLINE_POSE_H
9#define META_OCEAN_TRACKING_OFFLINE_OFFLINE_POSE_H
10
12
14
16
17namespace Ocean
18{
19
20namespace Tracking
21{
22
23namespace Offline
24{
25
26// Forward declaration.
27class OfflinePose;
28
29/**
30 * Definition of a shift vector holding offline poses.
31 * @ingroup trackingoffline
32 */
34
35/**
36 * This class encapsulates the tracking pose data.
37 * The pose is combined with a unique id and an abstract quality parameters.<br>
38 * @ingroup trackingoffline
39 */
41{
42 public:
43
44 /**
45 * Creates a default pose object.
46 */
47 OfflinePose() = default;
48
49 /**
50 * Creates a new pose object.
51 * @param id The id of the pose
52 * @param transformation The transformation of this pose
53 * @param quality Abstract quality parameter of the pose
54 */
55 inline OfflinePose(const unsigned int id, const HomogenousMatrix4& transformation, const Scalar quality = -1.0);
56
57 /**
58 * Returns the transformation of this pose.
59 * @return Frame pose
60 */
61 inline const HomogenousMatrix4& transformation() const;
62
63 /**
64 * Returns the abstract quality parameter of this pose.
65 * This parameter might have individual meanings for individual tracker implementations.<br>
66 * @return Pose quality
67 */
68 inline Scalar quality() const;
69
70 /**
71 * Returns the id of this frame.
72 * @return Frame id
73 */
74 inline unsigned int id() const;
75
76 /**
77 * Sets or changes the transformation of this pose object.
78 * @param transformation The transformation to be set
79 */
81
82 /**
83 * Sets or changes the abstract quality parameters of this pose object.
84 * @param quality The quality to be set
85 */
86 inline void setQuality(const Scalar quality);
87
88 /**
89 * Sets or changes the id of this pose object.
90 * @param id Id to be set
91 */
92 inline void setId(const unsigned int id);
93
94 /**
95 * Returns whether this pose holds a valid transformation.
96 * @return True, if so
97 */
98 inline bool isValid() const;
99
100 /**
101 * Returns whether this object holds a valid id and a valid pose.
102 * @return True, if so
103 */
104 explicit inline operator bool() const;
105
106 /**
107 * Compares two objects and returns whether this object has a higher quality parameter than the second one.
108 * @param object Second pose object
109 * @return True, if so
110 */
111 inline bool operator<(const OfflinePose& object) const;
112
113 /**
114 * Extracts the transformations from a set of offline pose objects.
115 * @param offlinePoses Offline pose object from that the transformations will be extracted
116 */
118
119 protected:
120
121 /// Pose id.
122 unsigned int id_ = (unsigned int)(-1);
123
124 /// The transformation of this pose.
126
127 /// Pose quality.
129};
130
131inline OfflinePose::OfflinePose(const unsigned int id, const HomogenousMatrix4& transformation, const Scalar quality) :
132 id_(id),
133 transformation_(transformation),
134 quality_(quality)
135{
136 // nothing to do here
137}
138
140{
141 return transformation_;
142}
143
144inline unsigned int OfflinePose::id() const
145{
146 return id_;
147}
148
150{
151 return quality_;
152}
153
154inline void OfflinePose::setTransformation(const HomogenousMatrix4& transformation)
155{
157}
158
159inline void OfflinePose::setQuality(const Scalar quality)
160{
162}
163
164inline void OfflinePose::setId(const unsigned int id)
165{
166 id_ = id;
167}
168
169inline bool OfflinePose::isValid() const
170{
171 return transformation_.isValid();
172}
173
174inline OfflinePose::operator bool() const
175{
176 return id_ != (unsigned int)(-1) && transformation_.isValid();
177}
178
179inline bool OfflinePose::operator<(const OfflinePose& object) const
180{
181 return quality_ > object.quality_;
182}
183
185{
186 ShiftVector<HomogenousMatrix4> result(offlinePoses.firstIndex(), offlinePoses.size());
187
188 for (ShiftVector<HomogenousMatrix4>::Index n = offlinePoses.firstIndex(); n < ShiftVector<HomogenousMatrix4>::Index(offlinePoses.firstIndex() + offlinePoses.size()); ++n)
189 {
190 result[n] = offlinePoses[n].transformation();
191 }
192
193 return result;
194}
195
196}
197
198}
199
200}
201
202#endif // META_OCEAN_TRACKING_OFFLINE_OFFLINE_POSE_H
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1806
This class implements a vector with shifted elements.
Definition ShiftVector.h:27
size_t size() const
Returns the number of elements that are stored by this object.
Definition ShiftVector.h:490
std::ptrdiff_t Index
Definition of an element index.
Definition ShiftVector.h:38
Index firstIndex() const
Returns the index of the first element of this object.
Definition ShiftVector.h:416
This class encapsulates the tracking pose data.
Definition OfflinePose.h:41
unsigned int id_
Pose id.
Definition OfflinePose.h:122
Scalar quality() const
Returns the abstract quality parameter of this pose.
Definition OfflinePose.h:149
void setQuality(const Scalar quality)
Sets or changes the abstract quality parameters of this pose object.
Definition OfflinePose.h:159
OfflinePose()=default
Creates a default pose object.
bool operator<(const OfflinePose &object) const
Compares two objects and returns whether this object has a higher quality parameter than the second o...
Definition OfflinePose.h:179
HomogenousMatrix4 transformation_
The transformation of this pose.
Definition OfflinePose.h:125
unsigned int id() const
Returns the id of this frame.
Definition OfflinePose.h:144
void setTransformation(const HomogenousMatrix4 &transformation)
Sets or changes the transformation of this pose object.
Definition OfflinePose.h:154
const HomogenousMatrix4 & transformation() const
Returns the transformation of this pose.
Definition OfflinePose.h:139
bool isValid() const
Returns whether this pose holds a valid transformation.
Definition OfflinePose.h:169
static ShiftVector< HomogenousMatrix4 > offlinePoses2transformations(const OfflinePoses &offlinePoses)
Extracts the transformations from a set of offline pose objects.
Definition OfflinePose.h:184
void setId(const unsigned int id)
Sets or changes the id of this pose object.
Definition OfflinePose.h:164
Scalar quality_
Pose quality.
Definition OfflinePose.h:128
float Scalar
Definition of a scalar type.
Definition Math.h:129
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
ShiftVector< OfflinePose > OfflinePoses
Definition of a shift vector holding offline poses.
Definition OfflinePose.h:33
The namespace covering the entire Ocean framework.
Definition Accessor.h:15