Ocean
SLAMPlaneTracker.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_SLAM_TRACKER_PLANAR_H
9 #define META_OCEAN_TRACKING_OFFLINE_SLAM_TRACKER_PLANAR_H
10 
14 
16 
17 #include "ocean/cv/SubRegion.h"
18 
20 
22 
23 namespace Ocean
24 {
25 
26 namespace Tracking
27 {
28 
29 namespace Offline
30 {
31 
32 // Forward declaration.
33 class SLAMPlaneTracker;
34 
35 /**
36  * Definition of an object reference holding a SLAMPlaneTracker object.
37  * @see SLAMPlaneTracker.
38  * @ingroup trackingoffline
39  */
41 
42 /**
43  * This class implements a SLAM tracker.
44  * @ingroup trackingoffline
45  */
46 class OCEAN_TRACKING_OFFLINE_EXPORT SLAMPlaneTracker :
47  virtual public FrameTracker,
48  virtual public PlaneTracker
49 {
50  protected:
51 
52  /**
53  * Definition of a shift vector holding homographies.
54  */
56 
57  /**
58  * Definition of a shift vector holding image point pairs.
59  */
61 
62  /**
63  * This class implements a homography tracker component that determines an accurate homography for the planar tracking sub-region between successive frames.
64  * Further, this component determines an initial 3D plane that is extracted from the tracked homographies.<br>
65  * Commonly, the accuracy of the plane's normal is in a range of a few degrees.<br>
66  */
68  {
69  protected:
70 
71  /**
72  * Definition of a pair of normals.
73  */
74  typedef std::pair<Vector3, Vector3> NormalPair;
75 
76  /**
77  * Definition of a shift vector holding normal pairs.
78  */
80 
81  public:
82 
83  /**
84  * Creates a new homography tracking component object.
85  * @param parent The parent tracker object that invokes this component
86  * @param pinholeCamera The pinhole camera profile that will be used for homography tracking
87  * @param resultingPlane The initial 3D plane that has been extracted from the homographies
88  * @param maxPlaneAngle Maximal angle between plane normals so that they count as similar
89  * @param optimizedCamera Optional resulting optimized camera profile
90  */
91  HomographyTrackerComponent(SLAMPlaneTracker& parent, const PinholeCamera& pinholeCamera, Plane3& resultingPlane, const Scalar maxPlaneAngle = Numeric::deg2rad(5), PinholeCamera* optimizedCamera = nullptr);
92 
93  /**
94  * Destructor
95  */
96  inline ~HomographyTrackerComponent() override;
97 
98  protected:
99 
100  /**
101  * Applies one component step.
102  * @see TrackerComponent::onFrame().
103  */
104  IterationResult onFrame(const unsigned int previousIndex, const unsigned int currentIndex, const unsigned int iteration, const unsigned int maximalIterations) override;
105 
106  /**
107  * Component start event function.
108  * @see TrackerComponent::onStart().
109  */
110  bool onStart(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override;
111 
112  /**
113  * Component start event function.
114  * @see TrackerComponent::onStop().
115  */
116  bool onStop(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override;
117 
118  /**
119  * Determines an initial homography for a planar sub-region between two frames.
120  * @param previousFramePyramid Frame pyramid of the previous frame
121  * @param currentFramePyramid Frame pyramid of the current frame
122  * @param previousSubRegion Sub-region that specifies the planar area in the previous frame
123  * @param homography Resulting homography that has been determined
124  * @param worker Optional worker object to distribute the computation
125  * @return True, if succeeded
126  */
127  bool frame2frameHomography(const CV::FramePyramid& previousFramePyramid, const CV::FramePyramid& currentFramePyramid, const CV::SubRegion& previousSubRegion, SquareMatrix3& homography, Worker* worker = nullptr);
128 
129  /**
130  * Optimizes the homography between two frames.
131  * @param previousFramePyramid Frame pyramid of the previous frame
132  * @param currentFrame Current frame
133  * @param previousSubRegion Sub region defining the planar area in the previous frame
134  * @param homography Already known homography between the previous and the current frame, the homography transforms points in the previous frame to points in the current frame
135  * @param optimizedHomography Resulting optimized homography
136  * @param previousImagePoints Resulting image points in the previous frame that have been used to optimized the homography
137  * @param currentImagePoints Resulting image points in the current frame that have been used to optimized the homography, each point corresponds to one point in the previous frame
138  * @param worker Optional worker object to distribute the computation
139  * @return True, if succeeded
140  */
141  bool optimizeHomography(const CV::FramePyramid& previousFramePyramid, const Frame& currentFrame, const CV::SubRegion& previousSubRegion, const SquareMatrix3& homography, SquareMatrix3& optimizedHomography, Vectors2& previousImagePoints, Vectors2& currentImagePoints, Worker* worker = nullptr);
142 
143  /**
144  * Determines the two best matching plane candidates from the set of plane normals pairs that have been found during the homography factorizations.
145  * @param candidatePair Resulting pair of plane normal candidates
146  * @param maxAngle Maximal angle between two normals so that they count as similar, in radian
147  * @param lowerFrameIndex Index of the frame defining the lower (including) tracking boundary
148  * @param initialFrameIndex Index of the frame at that the tracking process will start
149  * @param upperFrameIndex Index of the frame defining the upper (including) tracking boundary
150  * @return True, if succeeded
151  */
152  bool determinePlaneCandidates(NormalPair& candidatePair, const Scalar maxAngle, const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex);
153 
154  /**
155  * Optimizes the camera profile that has been used to track the homography and to create the initial plane.
156  * This function takes a subset of all determined homographies and minimizes the global distances between image points in the initial and the remaining camera frames.<br>
157  * @param optimizedCamera Resulting optimized camera
158  * @param numberFrames Number of frames (and thus homographies) that are used to optimized the camera profile
159  * @return True, if succeeded
160  */
161  bool optimizeCamera(PinholeCamera& optimizedCamera, const unsigned int numberFrames = 10u);
162 
163  protected:
164 
165  /// The parent tracker invoking this component.
167 
168  /// The camera profile that is applied in this component.
170 
171  /// The maximal angle between two plane normals so that these normals count as similar.
173 
174  /// Random number generator.
176 
177  /// The set of pairs of image points that have been used to determine the individual homographies.
179 
180  /// The determined homographies of this component.
182 
183  /// The determined pairs of plane normals, one pair for each detected homography.
185 
186  /// Resulting plane.
188 
189  /// Optional resulting optimized camera profile.
191 
192  /// Frame pyramid of the initial frame.
194 
195  /// Intermediate frame pyramid.
197 
198  /// Intermediate homography frame.
200 
201  /// The progress event stack layer of this component.
203  };
204 
205  /**
206  * This class implements a plane verifier component that selects the unique valid plane from a set of two plane candidates.
207  * Homography provides two planes for points correspondences, the correct plane can be determined with this component.<br>
208  */
210  {
211  public:
212 
213  /**
214  * Creates a new component object.
215  * @param parent The parent tracker object that invokes this component
216  * @param pinholeCamera The pinhole camera profile that will be used for validation
217  * @param initialPose Initial pose that is connected with the first frame index and is valid for both plane candidates
218  * @param planeCandidates Two plane candidates, only one is correct for the given frame sequence
219  * @param initialSubRegion Sub-region defining the planar area in the initial frame
220  * @param resultingPlane Resulting plane that is correct for the frame sequence (this plane is one of the given plane candidates)
221  * @param maximalSqrDistance Maximal square distance between a projected plane point and the visible point in the camera frame to count as inlier, in pixel
222  */
223  ValidPlaneIdentifyComponent(SLAMPlaneTracker& parent, const PinholeCamera& pinholeCamera, const HomogenousMatrix4& initialPose, const Plane3 planeCandidates[2], const CV::SubRegion& initialSubRegion, Plane3& resultingPlane, const Scalar maximalSqrDistance = Scalar(3 * 3));
224 
225  /**
226  * Destructor
227  */
228  inline ~ValidPlaneIdentifyComponent() override;
229 
230  protected:
231 
232  /**
233  * Component decreasing start event function.
234  * This function is executed before the decreasing component iterations are applied.
235  * @return True, if the start has succeeded
236  */
237  bool onStartDecreasing() override;
238 
239  /**
240  * Applies one component step.
241  * @see TrackerComponent::onFrame().
242  */
243  IterationResult onFrame(const unsigned int previousIndex, const unsigned int currentIndex, const unsigned int iteration, const unsigned int maximalIterations) override;
244 
245  /**
246  * Component start event function.
247  * @see TrackerComponent::onStop().
248  */
249  bool onStop(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override;
250 
251  protected:
252 
253  /// Parent tracker that invokes this component.
255 
256  /// The camera profile that is applied.
258 
259  /// Initial camera pose for the frame index for that the tracking starts.
261 
262  /// Two previous camera poses, individual for each plane candidate.
263  HomogenousMatrix4 componentPreviousPoses_[2];
264 
265  /// The number of valid point correspondences, individual for each plane candidate.
266  unsigned int componentValidCorrespondences_[2];
267 
268  /// Two plane candidates, one is correct.
269  Plane3 componentPlaneCandidates_[2];
270 
271  /// 3D plane object points, individual for each plane candidate.
272  Vectors3 componentObjectPoints_[2];
273 
274  /// Initial sub-region defining the planar area in the initial frame.
276 
277  /// Initial image points lying within the planar area in the initial frame.
279 
280  /// Initial object points lying on the 3D plane, individual for each plane candidate.
281  Vectors3 componentInitialObjectPoints_[2];
282 
283  /// Maximal square distance between a projected 3D plane object point and a visible camera image point.
285 
286  /// Resulting valid plane.
288 
289  /// The image points of the previous frame.
291 
292  /// The image points of the current frame.
294  };
295 
296  /**
297  * This class implements a plane tracker component that is able to track a known plane and further is able to optimize the plane orientation.
298  */
300  {
301  public:
302 
303  /**
304  * Creates a new component object.
305  * @param parent The parent tracker object that invokes this component
306  * @param pinholeCamera The pinhole camera profile that is applied
307  * @param initialPose Initial pose that will be used for the initial tracking frame
308  * @param plane Known plane that will be tracked
309  * @param createStateEvents True, to create state events for the individual poses
310  * @param poses Optional resulting poses for each frame between lower and upper tracking boundary
311  * @param optimizedPlane Optional resulting optimized plane
312  */
313  PlaneTrackerComponent(SLAMPlaneTracker& parent, const PinholeCamera& pinholeCamera, const HomogenousMatrix4& initialPose, const Plane3& plane, const bool createStateEvents, OfflinePoses* poses, Plane3* optimizedPlane);
314 
315  /**
316  * Destructor
317  */
318  inline ~PlaneTrackerComponent() override;
319 
320  protected:
321 
322  /**
323  * Applies one component step.
324  * @see TrackerComponent::onFrame().
325  */
326  IterationResult onFrame(const unsigned int previousIndex, const unsigned int currentIndex, const unsigned int iteration, const unsigned int maximalIterations) override;
327 
328  /**
329  * Component start event function.
330  * @see TrackerComponent::onStart().
331  */
332  bool onStart(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override;
333 
334  /**
335  * Component start event function.
336  * @see TrackerComponent::onStop().
337  */
338  bool onStop(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override;
339 
340  /**
341  * Optimizes the pose for a given frame.
342  * @param previousFramePyramid Frame pyramid of the previous frame
343  * @param currentFrame Current frame
344  * @param previousSubRegion Sub region defining the planar area in the previous frame
345  * @param previousPose Known pose for the previous frame
346  * @param currentPose The known pose for the current frame
347  * @param optimizedPose Resulting optimized pose for the given frame pair
348  * @param previousImagePoints Resulting image points in the previous frame that have been used to optimized the pose
349  * @param currentImagePoints Resulting image points in the current frame that have been used to optimized the pose, each point corresponds to one point in the previous frame
350  * @param worker Optional worker object to distribute the computation
351  * @return True, if succeeded
352  */
353  bool optimizePose(const CV::FramePyramid& previousFramePyramid, const Frame& currentFrame, const CV::SubRegion& previousSubRegion, const HomogenousMatrix4& previousPose, const HomogenousMatrix4& currentPose, HomogenousMatrix4& optimizedPose, Vectors2& previousImagePoints, Vectors2& currentImagePoints, Worker* worker = nullptr);
354 
355  /**
356  * Optimizes the plane.
357  * @param optimizedPlane Resulting optimized plane
358  * @param numberFrames Number for frames that are used to optimize the plane
359  * @return True, if succeeded
360  */
361  bool optimizePlane(Plane3& optimizedPlane, const unsigned int numberFrames = 10u);
362 
363  protected:
364 
365  /// Parent tracker that invokes this component.
367 
368  /// The camera profile that is applied for tracking.
370 
371  /// The initial pose that is used for the initial frame.
373 
374  /// Plane that is be used for tracking.
376 
377  /// Statement whether this component creates state events for the individual poses.
379 
380  /// Optional resulting optimized plane.
382 
383  /// Optional resulting poses.
385 
386  /// Homographies that are detected during tracking, each homography is defined in relation to the initial tracking frame.
388 
389  /// The camera poses that are detected during tracking, one pose for each frame
391 
392  /// The set of pairs of image points that have been used to determine the individual poses.
394 
395  /// Frame pyramid of the initial frame.
397 
398  /// Intermediate frame pyramid.
400 
401  /// Intermediate homography frame.
403  };
404 
405  public:
406 
407  /**
408  * Creates a new tracker object.
409  */
411 
412  /**
413  * Destructs a tracker object.
414  */
415  ~SLAMPlaneTracker() override;
416 
417  /**
418  * Sets an initial tracking area defined by a set of 2D triangles located in the initial camera frame.
419  * Beware: Set the tracking area before the tracker has been started.<br>
420  * @param triangles The triangles defining the initial tracking area
421  * @return True, if succeed
422  */
423  bool setInitialTrackingArea(const Triangles2& triangles);
424 
425  /**
426  * Sets an initial tracking area defined by a set of 2D triangles located in the initial camera frame.
427  * Beware: Set the tracking area before the tracker has been started.<br>
428  * @param yMask The 8 bit binary mask defining the sub-region, pixel values not equal to 0xFF define the sub-region, must be valid
429  * @return True, if succeed
430  */
431  bool setInitialTrackingArea(const Frame& yMask);
432 
433  protected:
434 
435  /**
436  * Frame tracker run function.
437  * @see OfflineFrameTracker::applyFrameTracking().
438  */
439  bool applyFrameTracking(const FrameType& frameType) override;
440 
441  /**
442  * Determines an initial plane.
443  * @param lowerFrameIndex Index of the frame defining the lower (including) tracking boundary
444  * @param initialFrameIndex Index of the frame at that the tracking process will start
445  * @param upperFrameIndex Index of the frame defining the upper (including) tracking boundary
446  * @return True, if succeeded
447  */
448  bool determinePlane(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex);
449 
450  /**
451  * Determines an initial plane.
452  * @param pinholeCamera The pinhole camera profile to be applied
453  * @param lowerFrameIndex Index of the frame defining the lower (including) tracking boundary
454  * @param initialFrameIndex Index of the frame at that the tracking process will start
455  * @param upperFrameIndex Index of the frame defining the upper (including) tracking boundary
456  * @param optimizedPlane Resulting optimized plane
457  * @param optimizedCamera Optional resulting optimized camera
458  * @return True, if succeeded
459  */
460  bool determineInitialPlane(const PinholeCamera& pinholeCamera, const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex, Plane3& optimizedPlane, PinholeCamera* optimizedCamera = nullptr);
461 
462  /**
463  * Optimizes the initial plane.
464  * @param lowerFrameIndex Index of the frame defining the lower (including) tracking boundary
465  * @param initialFrameIndex Index of the frame at that the tracking process will start
466  * @param upperFrameIndex Index of the frame defining the upper (including) tracking boundary
467  * @return True, if succeeded
468  */
469  bool optimizePlane(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex);
470 
471  /**
472  * Tracks a known plane and can determines the camera poses or/and optimize the plane.
473  * @param pinholeCamera The pinhole camera profile to be applied
474  * @param plane 3D plane to be tracked
475  * @param lowerFrameIndex Index of the frame defining the lower (including) tracking boundary
476  * @param initialFrameIndex Index of the frame at that the tracking process will start
477  * @param upperFrameIndex Index of the frame defining the upper (including) tracking boundary
478  * @param createStateEvents True, to create state events for the individual poses
479  * @param optimizedPlane Optional resulting optimized plane
480  * @param poses Optional resulting camera poses
481  * @return True, if succeeded
482  */
483  bool trackPlane(const PinholeCamera& pinholeCamera, const Plane3& plane, const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex, const bool createStateEvents, Plane3* optimizedPlane = nullptr, OfflinePoses* poses = nullptr);
484 
485  /**
486  * Updates the plane of this tracker and invokes the corresponding state event(s).
487  * @see PlaneTracker::updatePlane().
488  */
489  void updatePlane(const Plane3& plane) override;
490 
491  /**
492  * Updates the camera of this tracker and invokes the corresponding state event(s).
493  * @see FrameTracker::updateCamera().
494  */
495  void updateCamera(const PinholeCamera& pinholeCamera) override;
496 
497  /**
498  * Updates the tracker object transformation using the current camera profile and plane of this tracker.
499  * @return True, if succeeded
500  */
502 
503  protected:
504 
505  /// The initial pose that is defined for the first frame index, this pose is the default pose: locking towards the negative z-axis with y-axis as up vector at the position (0, 0, 0).
507 
508  /// The user-defined sub-region for the initial tracking frame.
510 };
511 
513 {
514  // Nothing else to do.
515 }
516 
518 {
519  // Nothing else to do.
520 }
521 
523 {
524  // Nothing else to do.
525 }
526 
527 }
528 
529 }
530 
531 }
532 
533 #endif // META_OCEAN_TRACKING_OFFLINE_SLAM_TRACKER_PLANAR_H
This class implements a frame pyramid.
Definition: FramePyramid.h:37
This class implement a sub-region either defined by 2D triangles or defined by a binary mask.
Definition: SubRegion.h:32
This class implements Ocean's image class.
Definition: Frame.h:1760
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition: Frame.h:30
static constexpr T deg2rad(const T deg)
Converts deg to rad.
Definition: Numeric.h:3232
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition: SmartObjectRef.h:90
This class implements the base class for all components of a frame tracker.
Definition: FrameTracker.h:196
IterationResult
Definition of individual results for the component iterations.
Definition: FrameTracker.h:62
This class implements the base class for all visual offline tracker using frames to provide the track...
Definition: FrameTracker.h:46
This class implements an event stack layer object that pushes the relative progress parameters on the...
Definition: OfflineTracker.h:163
This class implements the abstract base class for all plane trackers.
Definition: PlaneTracker.h:42
This class implements a homography tracker component that determines an accurate homography for the p...
Definition: SLAMPlaneTracker.h:68
SLAMPlaneTracker & componentParent_
The parent tracker invoking this component.
Definition: SLAMPlaneTracker.h:166
Homographies componentHomographies_
The determined homographies of this component.
Definition: SLAMPlaneTracker.h:181
CV::FramePyramid componentInitialFramePyramid_
Frame pyramid of the initial frame.
Definition: SLAMPlaneTracker.h:193
const Scalar componentMaxPlaneAngle_
The maximal angle between two plane normals so that these normals count as similar.
Definition: SLAMPlaneTracker.h:172
Frame componentIntermediateHomographyFrame_
Intermediate homography frame.
Definition: SLAMPlaneTracker.h:199
HomographyTrackerComponent(SLAMPlaneTracker &parent, const PinholeCamera &pinholeCamera, Plane3 &resultingPlane, const Scalar maxPlaneAngle=Numeric::deg2rad(5), PinholeCamera *optimizedCamera=nullptr)
Creates a new homography tracking component object.
const PinholeCamera componentCamera_
The camera profile that is applied in this component.
Definition: SLAMPlaneTracker.h:169
NormalPairs componentNormalPairs_
The determined pairs of plane normals, one pair for each detected homography.
Definition: SLAMPlaneTracker.h:184
ImagePointsPairs componentImagePointsPairs_
The set of pairs of image points that have been used to determine the individual homographies.
Definition: SLAMPlaneTracker.h:178
bool determinePlaneCandidates(NormalPair &candidatePair, const Scalar maxAngle, const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex)
Determines the two best matching plane candidates from the set of plane normals pairs that have been ...
ShiftVector< NormalPair > NormalPairs
Definition of a shift vector holding normal pairs.
Definition: SLAMPlaneTracker.h:79
bool optimizeCamera(PinholeCamera &optimizedCamera, const unsigned int numberFrames=10u)
Optimizes the camera profile that has been used to track the homography and to create the initial pla...
bool optimizeHomography(const CV::FramePyramid &previousFramePyramid, const Frame &currentFrame, const CV::SubRegion &previousSubRegion, const SquareMatrix3 &homography, SquareMatrix3 &optimizedHomography, Vectors2 &previousImagePoints, Vectors2 &currentImagePoints, Worker *worker=nullptr)
Optimizes the homography between two frames.
bool frame2frameHomography(const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid &currentFramePyramid, const CV::SubRegion &previousSubRegion, SquareMatrix3 &homography, Worker *worker=nullptr)
Determines an initial homography for a planar sub-region between two frames.
IterationResult onFrame(const unsigned int previousIndex, const unsigned int currentIndex, const unsigned int iteration, const unsigned int maximalIterations) override
Applies one component step.
ScopedEventStackLayer componentScopedEventLayer_
The progress event stack layer of this component.
Definition: SLAMPlaneTracker.h:202
std::pair< Vector3, Vector3 > NormalPair
Definition of a pair of normals.
Definition: SLAMPlaneTracker.h:74
CV::FramePyramid componentIntermediateFramePyramid_
Intermediate frame pyramid.
Definition: SLAMPlaneTracker.h:196
~HomographyTrackerComponent() override
Destructor.
Definition: SLAMPlaneTracker.h:512
bool onStop(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override
Component start event function.
PinholeCamera * componentResultingOptimizedCamera_
Optional resulting optimized camera profile.
Definition: SLAMPlaneTracker.h:190
RandomGenerator componentRandomGenerator_
Random number generator.
Definition: SLAMPlaneTracker.h:175
Plane3 & componentResultingPlane_
Resulting plane.
Definition: SLAMPlaneTracker.h:187
bool onStart(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override
Component start event function.
This class implements a plane tracker component that is able to track a known plane and further is ab...
Definition: SLAMPlaneTracker.h:300
bool optimizePlane(Plane3 &optimizedPlane, const unsigned int numberFrames=10u)
Optimizes the plane.
~PlaneTrackerComponent() override
Destructor.
Definition: SLAMPlaneTracker.h:522
const Plane3 & componentPlane_
Plane that is be used for tracking.
Definition: SLAMPlaneTracker.h:375
const PinholeCamera & componentCamera_
The camera profile that is applied for tracking.
Definition: SLAMPlaneTracker.h:369
const bool componentCreateStateEvents_
Statement whether this component creates state events for the individual poses.
Definition: SLAMPlaneTracker.h:378
OfflinePoses * componentResultingPoses_
Optional resulting poses.
Definition: SLAMPlaneTracker.h:384
bool optimizePose(const CV::FramePyramid &previousFramePyramid, const Frame &currentFrame, const CV::SubRegion &previousSubRegion, const HomogenousMatrix4 &previousPose, const HomogenousMatrix4 &currentPose, HomogenousMatrix4 &optimizedPose, Vectors2 &previousImagePoints, Vectors2 &currentImagePoints, Worker *worker=nullptr)
Optimizes the pose for a given frame.
Frame componentIntermediateHomographyFrame_
Intermediate homography frame.
Definition: SLAMPlaneTracker.h:402
SLAMPlaneTracker & componentParent_
Parent tracker that invokes this component.
Definition: SLAMPlaneTracker.h:366
Homographies componentHomographies_
Homographies that are detected during tracking, each homography is defined in relation to the initial...
Definition: SLAMPlaneTracker.h:387
bool onStop(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override
Component start event function.
const HomogenousMatrix4 & componentInitialPose_
The initial pose that is used for the initial frame.
Definition: SLAMPlaneTracker.h:372
CV::FramePyramid componentIntermediateFramePyramid_
Intermediate frame pyramid.
Definition: SLAMPlaneTracker.h:399
CV::FramePyramid componentInitialFramePyramid_
Frame pyramid of the initial frame.
Definition: SLAMPlaneTracker.h:396
Plane3 * componentResultingPlane_
Optional resulting optimized plane.
Definition: SLAMPlaneTracker.h:381
PlaneTrackerComponent(SLAMPlaneTracker &parent, const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &initialPose, const Plane3 &plane, const bool createStateEvents, OfflinePoses *poses, Plane3 *optimizedPlane)
Creates a new component object.
bool onStart(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override
Component start event function.
OfflinePoses componentPoses_
The camera poses that are detected during tracking, one pose for each frame.
Definition: SLAMPlaneTracker.h:390
IterationResult onFrame(const unsigned int previousIndex, const unsigned int currentIndex, const unsigned int iteration, const unsigned int maximalIterations) override
Applies one component step.
ImagePointsPairs componentImagePointsPairs_
The set of pairs of image points that have been used to determine the individual poses.
Definition: SLAMPlaneTracker.h:393
This class implements a plane verifier component that selects the unique valid plane from a set of tw...
Definition: SLAMPlaneTracker.h:210
SLAMPlaneTracker & componentParent_
Parent tracker that invokes this component.
Definition: SLAMPlaneTracker.h:254
Vectors2 componentPreviousImagePoints_
The image points of the previous frame.
Definition: SLAMPlaneTracker.h:290
const CV::SubRegion & componentInitialSubRegion_
Initial sub-region defining the planar area in the initial frame.
Definition: SLAMPlaneTracker.h:275
const PinholeCamera componentCamera_
The camera profile that is applied.
Definition: SLAMPlaneTracker.h:257
Plane3 & componentResultingPlane_
Resulting valid plane.
Definition: SLAMPlaneTracker.h:287
bool onStop(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override
Component start event function.
Vectors2 componentCurrentImagePoints_
The image points of the current frame.
Definition: SLAMPlaneTracker.h:293
~ValidPlaneIdentifyComponent() override
Destructor.
Definition: SLAMPlaneTracker.h:517
const Scalar componentMaximalSqrDistance_
Maximal square distance between a projected 3D plane object point and a visible camera image point.
Definition: SLAMPlaneTracker.h:284
Vectors2 componentInitialImagePoints_
Initial image points lying within the planar area in the initial frame.
Definition: SLAMPlaneTracker.h:278
bool onStartDecreasing() override
Component decreasing start event function.
const HomogenousMatrix4 & componentInitialPose_
Initial camera pose for the frame index for that the tracking starts.
Definition: SLAMPlaneTracker.h:260
IterationResult onFrame(const unsigned int previousIndex, const unsigned int currentIndex, const unsigned int iteration, const unsigned int maximalIterations) override
Applies one component step.
ValidPlaneIdentifyComponent(SLAMPlaneTracker &parent, const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &initialPose, const Plane3 planeCandidates[2], const CV::SubRegion &initialSubRegion, Plane3 &resultingPlane, const Scalar maximalSqrDistance=Scalar(3 *3))
Creates a new component object.
This class implements a SLAM tracker.
Definition: SLAMPlaneTracker.h:49
bool determinePlane(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex)
Determines an initial plane.
ShiftVector< Geometry::NonLinearOptimizationPlane::ImagePointsPair > ImagePointsPairs
Definition of a shift vector holding image point pairs.
Definition: SLAMPlaneTracker.h:60
bool optimizePlane(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex)
Optimizes the initial plane.
~SLAMPlaneTracker() override
Destructs a tracker object.
ShiftVector< SquareMatrix3 > Homographies
Definition of a shift vector holding homographies.
Definition: SLAMPlaneTracker.h:55
CV::SubRegion initialSubRegion_
The user-defined sub-region for the initial tracking frame.
Definition: SLAMPlaneTracker.h:509
bool setInitialTrackingArea(const Frame &yMask)
Sets an initial tracking area defined by a set of 2D triangles located in the initial camera frame.
const HomogenousMatrix4 initialPose_
The initial pose that is defined for the first frame index, this pose is the default pose: locking to...
Definition: SLAMPlaneTracker.h:506
bool applyFrameTracking(const FrameType &frameType) override
Frame tracker run function.
bool updateObjectTransformation()
Updates the tracker object transformation using the current camera profile and plane of this tracker.
bool trackPlane(const PinholeCamera &pinholeCamera, const Plane3 &plane, const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex, const bool createStateEvents, Plane3 *optimizedPlane=nullptr, OfflinePoses *poses=nullptr)
Tracks a known plane and can determines the camera poses or/and optimize the plane.
SLAMPlaneTracker()
Creates a new tracker object.
void updatePlane(const Plane3 &plane) override
Updates the plane of this tracker and invokes the corresponding state event(s).
bool setInitialTrackingArea(const Triangles2 &triangles)
Sets an initial tracking area defined by a set of 2D triangles located in the initial camera frame.
bool determineInitialPlane(const PinholeCamera &pinholeCamera, const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex, Plane3 &optimizedPlane, PinholeCamera *optimizedCamera=nullptr)
Determines an initial plane.
void updateCamera(const PinholeCamera &pinholeCamera) override
Updates the camera of this tracker and invokes the corresponding state event(s).
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Triangle2 > Triangles2
Definition of a vector holding 2D triangles.
Definition: Triangle2.h:57
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition: Vector3.h:65
SmartObjectRef< SLAMPlaneTracker, OfflineTracker > SLAMPlaneTrackerRef
Definition of an object reference holding a SLAMPlaneTracker object.
Definition: SLAMPlaneTracker.h:33
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15