Ocean
PatternTrackerCore6DOF.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_PATTERN_PATTERN_TRACKER_CORE_6DOF_H
9 #define META_OCEAN_TRACKING_PATTERN_PATTERN_TRACKER_CORE_6DOF_H
10 
12 
13 #include "ocean/base/Frame.h"
14 #include "ocean/base/Lock.h"
16 #include "ocean/base/Timestamp.h"
17 #include "ocean/base/Worker.h"
18 
19 #include "ocean/cv/FramePyramid.h"
20 #include "ocean/cv/SubRegion.h"
21 
23 
25 
27 #include "ocean/math/AnyCamera.h"
28 
30 
31 namespace Ocean
32 {
33 
34 namespace Tracking
35 {
36 
37 namespace Pattern
38 {
39 
40 /**
41  * This class implements the core of the 6DOF feature tracker for planar patterns.
42  * This 'core' class is separated from the general PatternTracker6DOF class to avoid any virtual functions.<br>
43  * Virtual functions may increase the binary size as the compiler/linker may not be able to identify unused virtual functions as 'dead', and thus the linker will not be able to strip such functions.<br>
44  * However, if the PatternTracker6DOF's object oriented capability is not needed anyway the usage of this core class is recommended (especially if the binary size matters).
45  * @see PatternTracker6DOF.
46  * @ingroup trackingpattern
47  */
48 class OCEAN_TRACKING_PATTERN_EXPORT PatternTrackerCore6DOF
49 {
50  public:
51 
52  /**
53  * Set of configurable parameters for the tracker.
54  */
55  class OCEAN_TRACKING_PATTERN_EXPORT Options
56  {
57  public:
58 
59  /**
60  * Creates a new options object.
61  */
63 
64  public:
65 
66  /// The maximal number of patterns that can be visible concurrently, with range [1, infinity). 0 to allow as many as possible
67  unsigned int maxConcurrentlyVisiblePattern_ = 1u;
68 
69  /// The maximal time used for pattern recognition for each frame in seconds, with range (0, infinity). 0 to use a default value
70  double maxRecognitionTime_ = 0.0;
71 
72  /// Time in seconds to wait between recognition attempts when at least one pattern is currently being tracked.
73  double recognitionCadenceWithTrackedPatterns_ = 0.5;
74 
75  /// Time in seconds to wait between recognition attempts when no patterns are currently being tracked.
76  double recognitionCadenceWithoutTrackedPatterns_ = 0.0;
77 
78  /// The number of iterations to run RANSAC when attempting to verify a newly recognized target.
79  unsigned int recognitionRansacIterations_ = 50u;
80 
81  /// True, to skip frame-to-frame tracking and to apply a full re-detection for every frame.
82  bool noFrameToFrameTracking_ = false;
83 
84 #ifdef OCEAN_PLATFORM_BUILD_ANDROID
85 
86  /// True, to apply a downsampling on Android devices to improve performance on low end devices.
87  bool downsampleInputImageOnAndroid_ = true;
88 #endif
89  };
90 
91  protected:
92 
93  /**
94  * Definition of the descriptor to be used.
95  */
97 
98  /**
99  * Definition of the descriptors to be used.
100  */
102 
103  /// The maximal distance between two descriptors to be considered as similar.
104  static constexpr unsigned int maximalDescriptorDistance_ = (unsigned int)(Descriptor::size() * 8) * 25u / 100u; // 25% of the descriptor bits
105 
106  /**
107  * Definition of a lightweight 3D feature map holding 3D object points and descriptors for all features in the map.
108  */
110  {
111  public:
112 
113  /**
114  * Default constructor.
115  */
116  FeatureMap() = default;
117 
118  /**
119  * Creates a new feature map for a planar 3D object (an image placed in the x-z plane).
120  * @param yFrame The image for which the feature map will be created, with pixel format FORMAT_Y8, must be valid
121  * @param width The width of the image in pixel, with range [1, infinity)
122  * @param height The height of the image in pixel, with range [1, infinity)
123  * @param yFramePaddingElements The number of padding elements at the end of each image row, in elements, with range [0, infinity)
124  * @param dimension The dimension of the feature map (of the image), with range (0, infinity)x[0, infinity), if the y-value is 0 the image's aspect ratio is used to determine the size of the y-dimension
125  * @param worker Optional worker object to distribute the computation
126  */
127  FeatureMap(const uint8_t* yFrame, const unsigned int width, const unsigned int height, const unsigned int yFramePaddingElements, const Vector2& dimension, Worker* worker = nullptr);
128 
129  /**
130  * Returns the 3D object points of all map features.
131  * @return The map's object points
132  */
133  inline const Vectors3& objectPoints() const;
134 
135  /**
136  * Returns the descriptor associated with the 3D object points of this map.
137  * @return The map's feature descriptors, one for each 3D object point
138  */
139  inline const Descriptors& descriptors() const;
140 
141  protected:
142 
143  /// The 3D locations of all features in this map.
145 
146  /// The descriptors of all features, one for each 3D object point location.
148  };
149 
150  /**
151  * This class stores the information necessary for one tracking pattern.
152  */
153  class Pattern
154  {
155  protected:
156 
157  /**
158  * Definition of a vector holding 2D feature positions.
159  */
160  typedef std::vector<Vectors2> PointLayers;
161 
162  public:
163 
164  /**
165  * Creates a new invalid pattern object.
166  */
167  Pattern() = default;
168 
169  /**
170  * Creates a new pattern object by a given frame and pattern dimension.
171  * @param yFrame The 8 bit grayscale frame (with Y8 pixel format, and pixel origin in the upper left corner) specifying the tracking pattern, must be valid
172  * @param width The width of the given grayscale frame in pixel, with range [1, infinity)
173  * @param height The height of the given grayscale frame in pixel, with range [1, infinity)
174  * @param yFramePaddingElements The number of padding elements at the end of each row, in elements, with range [0, infinity)
175  * @param dimension The dimension of the tracking pattern, with range (0, infinity)x(0, infinity)
176  * @param worker Optional worker object to distribute the computation
177  */
178  Pattern(const uint8_t* yFrame, const unsigned int width, const unsigned int height, const unsigned int yFramePaddingElements, const Vector2& dimension, Worker* worker = nullptr);
179 
180  /**
181  * Returns the feature map of this pattern.
182  * @return The pattern's feature map
183  */
184  inline const FeatureMap& featureMap() const;
185 
186  /**
187  * Returns the frame pyramid of the image defining the tracking pattern.
188  * @return Pattern frame pyramid
189  */
190  inline const CV::FramePyramid& pyramid() const;
191 
192  /**
193  * Returns the dimension of the tracking object defined in the tracker coordinate system.
194  * @return Pattern dimension
195  */
196  inline const Vector2& dimension() const;
197 
198  /**
199  * Returns the first 3D corner position of the tracking pattern in the tracker coordinate system. Only to be used for planar patterns.
200  * @return The upper left corner of the tracking pattern (for a planar pattern, identical with the origin of the world coordinate system).
201  */
202  inline Vector3 corner0() const;
203 
204  /**
205  * Returns the second 3D corner position of the tracking pattern in the tracker coordinate system. Only to be used for planar patterns.
206  * @return The lower left corner of the tracking pattern
207  */
208  inline Vector3 corner1() const;
209 
210  /**
211  * Returns the third 3D corner position of the tracking pattern in the tracker coordinate system. Only to be used for planar patterns.
212  * @return The lower right corner of the tracking pattern
213  */
214  inline Vector3 corner2() const;
215 
216  /**
217  * Returns the fourth 3D corner position of the tracking pattern in the tracker coordinate system. Only to be used for planar patterns.
218  * @return The upper right corner of the tracking pattern
219  */
220  inline Vector3 corner3() const;
221 
222  /**
223  * Returns the two 3D triangles covering the tracking area of this tracking pattern.
224  * @return Two 3D triangles
225  */
226  inline Triangles3 triangles3() const;
227 
228  /**
229  * Returns the two projected 2D triangles specifying the tracking pattern in the camera frame as seen with the previous pose (which is stored in this object).
230  * Beware: The previous pose must be valid.<br>
231  * @param pinholeCamera The pinhole camera profile defining the projection, must be valid
232  * @return The two projected 2D triangles
233  */
234  inline Triangles2 triangles2(const PinholeCamera& pinholeCamera) const;
235 
236  /**
237  * Returns the two projected 2D triangles specifying the tracking pattern in the camera frame as seen with a given pose.
238  * @param pinholeCamera The pinhole camera profile defining the projection, must be valid
239  * @param pose The pose defining the camera position and orientation, must be valid
240  * @return The two projected 2D triangles
241  */
242  inline Triangles2 triangles2(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& pose) const;
243 
244  /**
245  * Returns the previous camera pose from which this tracking pattern has been seen.
246  * @return Previous camera pose, if any
247  */
248  inline const HomogenousMatrix4& previousPose() const;
249 
250  /**
251  * Returns the previous camera pose from which this tracking pattern has been seen.
252  * @return Previous camera pose, if any
253  */
254  inline HomogenousMatrix4& previousPose();
255 
256  /**
257  * Returns the 3D object points of this pattern which have been used in the previous (or current) tracking iteration.
258  * @return 3D object points lying in the pattern plane, each point corresponds with one image point
259  * @see imagePoints().
260  */
261  inline const Vectors3& objectPoints() const;
262 
263  /**
264  * Returns the 3D object points of this pattern which have been used in the previous (or current) tracking iteration.
265  * @return 3D object points lying in the pattern plane, each point corresponds with one image point
266  * @see imagePoints().
267  */
268  inline Vectors3& objectPoints();
269 
270  /**
271  * Returns the 2D image points of this pattern which have been used in the previous (or current) tracking iteration.
272  * @return 2D image points, each point corresponds with one object point
273  * @see objectPoints().
274  */
275  inline const Vectors2& imagePoints() const;
276 
277  /**
278  * Returns the 2D image points of this pattern which have been used in the previous (or current) tracking iteration.
279  * @return 2D image points, each point corresponds with one object point
280  * @see objectPoints().
281  */
282  inline Vectors2& imagePoints();
283 
284  /**
285  * Returns the 2D feature points from the pyramid frame of the pattern image.
286  * @param layer The index of the pyramid layer, with range [0, layer())
287  * @return The 2D feature points of the specified layer
288  * @see layer().
289  */
290  inline const Vectors2& referencePoints(const unsigned int layer) const;
291 
292  /**
293  * Returns the number of pyramid layers of the pattern image.
294  * @return The number of layers
295  * @see referencePoints().
296  */
297  inline unsigned int layers() const;
298 
299  /**
300  * Returns whether this pattern holds a valid/useful rough guess of the camera pose.
301  * @param poseGuess The resulting rough pose guess, if existing
302  * @param maximalAge The maximal age of the rough pose guess in seconds, with range [0, 2]
303  * @return True, if so
304  */
305  inline bool hasPoseGuess(HomogenousMatrix4& poseGuess, const double maximalAge = 0.5);
306 
307  /**
308  * Returns a guess of the current camera pose for this pattern.
309  * @param timestamp Optional timestamp of the pose guess
310  * @return pose The camera pose guess, if any
311  */
312  inline const HomogenousMatrix4& poseGuess(Timestamp* timestamp = nullptr);
313 
314  /**
315  * Sets a guess of the current (or next) camera pose for this pattern.
316  * @param pose guess The rough pose guess
317  * @param timestamp The timestamp of this guess
318  */
319  inline void setPoseGuess(const HomogenousMatrix4& pose, const Timestamp& timestamp);
320 
321  /**
322  * Returns whether this tracking pattern object is valid.
323  * @return True, if so
324  */
325  inline bool isValid() const;
326 
327  /**
328  * Resets the internal recognition states of this pattern while the actual feature map is untouched.
329  */
330  void reset();
331 
332  /**
333  * Returns whether this tracking pattern object is valid.
334  * @return True, if so
335  */
336  explicit inline operator bool() const;
337 
338  protected:
339 
340  /// The feature map of this pattern.
342 
343  /// The frame pyramid of the image specifying the pattern.
345 
346  /// The dimension of the tracking pattern defined in the tracker coordinate system as (x-axis, z-axis).
347  Vector2 dimension_ = Vector2(0, 0);
348 
349  /// The previous camera pose for this tacking pattern, if any
350  HomogenousMatrix4 world_T_previousCamera_ = HomogenousMatrix4(false);
351 
352  /// The 3D object points which have been used in the previous (or current) tracking iteration.
354 
355  /// The 2D image points which have been used in the previous (or current) tracking iteration.
357 
358  /// The point pyramid of the pattern image storing reference feature points for individual pattern resolutions.
360 
361  /// A rough guess of the camera pose for this pattern, if any.
362  HomogenousMatrix4 world_T_guessCamera_ = HomogenousMatrix4(false);
363 
364  /// The timestamp of the rough camera pose.
366  };
367 
368  /**
369  * Definition of a map holding pattern objects.
370  */
371  typedef std::map<unsigned int, Pattern> PatternMap;
372 
373  public:
374 
375  /**
376  * Creates a new feature tracker object.
377  * @param options Set of parameters for the tracker
378  */
379  explicit PatternTrackerCore6DOF(const Options& options = Options());
380 
381  /**
382  * Destructs a feature tracker object.
383  */
385 
386  /**
387  * Adds a new 2D tracking pattern (an image) to the tracker.
388  * The origin of the pattern will be located in the upper left corner of the given frame.<br>
389  * The pattern lies inside the x-z-plane with y-axis as up-vector.
390  * @param yFrame The 8 bit grayscale frame (with Y8 pixel format, and pixel origin in the upper left corner) specifying the tracking pattern, must be valid
391  * @param width The width of the given grayscale frame in pixel, with range [1, infinity)
392  * @param height The height of the given grayscale frame in pixel, with range [1, infinity)
393  * @param yFramePaddingElements The number of padding elements at the end of each row, in elements, with range [0, infinity)
394  * @param dimension The dimension of the tracking pattern in the tracker coordinate system, with range (0, infinity)x(-infinity, infinity)
395  * @param worker Optional worker object to distribute the computation
396  * @return The id of the tracking pattern, -1 if the pattern could not be added
397  * @see removePattern(), numberPattern(), setMaxConcurrentlyVisiblePattern().
398  */
399  unsigned int addPattern(const uint8_t* yFrame, const unsigned int width, const unsigned int height, const unsigned int yFramePaddingElements, const Vector2& dimension, Worker* worker = nullptr);
400 
401  /**
402  * Adds a new 2D tracking pattern (an image) to the tracker.
403  * The origin of the pattern will be located in the upper left corner of the given frame.<br>
404  * The pattern lies inside the x-z-plane with y-axis as up-vector.<br>
405  * This function takes a file in which the pattern is defined, the file can be a simple image or a feature map storing an additional hierarchy of feature points.
406  * @param filename The filename of the file storing the pattern information, must be valid
407  * @param dimension The dimension of the tracking pattern in the tracker coordinate system, with range (0, infinity)x(-infinity, infinity)
408  * @param worker Optional worker object to distribute the computation
409  * @return The id of the tracking pattern, -1 if the pattern could not be added
410  * @see removePattern(), numberPattern(), setMaxConcurrentlyVisiblePattern().
411  */
412  unsigned int addPattern(const std::string& filename, const Vector2& dimension, Worker* worker = nullptr);
413 
414  /**
415  * Removes a pattern from this tracker.
416  * @param patternId The id of the pattern to be removed
417  * @return True, if the defined pattern could be removed; False, if e.g., the pattern id is invalid
418  * @see removePatterns().
419  */
420  bool removePattern(const unsigned int patternId);
421 
422  /**
423  * Removes all patterns from this tracker.
424  * @return True, if all existing patterns could be removed
425  * @see removePattern().
426  */
428 
429  /**
430  * Executes the 6DOF tracking for a given frame.
431  * Beware: The frame type of the input image must not change between successive calls, reset the tracker in case the image resolution changes.
432  * @param yFrame The 8 bit grayscale frame (with Y8 pixel format, and pixel origin in the upper left corner) to be used for tracking (the frame's width and hight will be extracted from the camera profile), must be valid
433  * @param pinholeCamera The pinhole camera object defining the project, with same dimension as the given frame, must be valid
434  * @param yFramePaddingElements The number of padding elements at the end of each row, in elements, with range [0, infinity)
435  * @param frameIsUndistorted True, if the original input frame is undistorted and thus feature must not be undistorted explicitly
436  * @param timestamp The timestamp of the given frame, must be valid
437  * @param transformations Resulting 6DOF poses combined with the tracking ids
438  * @param world_R_camera Optional absolute orientation of the camera in the moment the frame was taken, defined in a coordinate system not related with the tracking objects, an invalid object otherwise
439  * @param worker Optional worker object
440  * @return True, if succeeded
441  */
442  bool determinePoses(const uint8_t* yFrame, const PinholeCamera& pinholeCamera, const unsigned int yFramePaddingElements, const bool frameIsUndistorted, const Timestamp& timestamp, VisualTracker::TransformationSamples& transformations, const Quaternion& world_R_camera = Quaternion(false), Worker* worker = nullptr);
443 
444  /**
445  * Returns the number of registered/added pattern.
446  * @return The number of existing pattern, with range [0, infinity)
447  * @see addPattern(), setMaxConcurrentlyVisiblePattern().
448  */
449  inline unsigned int numberPattern() const;
450 
451  /**
452  * Returns the maximal number of pattern that can be tracked concurrently within one frame.
453  * @return The number of pattern that can be tracked concurrently, with range [0, numberPattern()], 0 to track as much as possible, 1 by default
454  * @see setMaxConcurrentlyVisiblePattern(), numberPattern().
455  */
456  inline unsigned int maxConcurrentlyVisiblePattern() const;
457 
458  /**
459  * Sets the maximal number of pattern that can be tracked concurrently within one frame.
460  * @param maxConcurrentlyVisiblePattern The number of pattern that can be tracked concurrently, with range [0, infinity), 0 to track as much as possible
461  * @see maxConcurrentlyVisiblePattern(), numberPattern().
462  */
463  inline void setMaxConcurrentlyVisiblePattern(const unsigned int maxConcurrentlyVisiblePattern);
464 
465  /**
466  * Returns the latest 2D/3D correspondences for a pattern which has been used to determine the camera pose.
467  * This function is mainly intended for debugging and visualization purposes.
468  * @param patternId The id of the pattern for which the latest feature correspondences will be returned
469  * @param imagePoints The resulting 2D image points, empty if no pose is known
470  * @param objectPoints The resulting 3D object points, one for each 2D image point
471  * @param pattern_T_camera Optional resulting camera pose associated with the pattern and feature correspondences, nullptr if not of interest
472  * @return True, if succeeded
473  */
474  bool recentFeatureCorrespondences(const unsigned int patternId, Vectors2& imagePoints, Vectors3& objectPoints, HomogenousMatrix4* pattern_T_camera = nullptr) const;
475 
476  /**
477  * Resets the tracker's states but keeps all registered pattern.
478  * This function should be used e.g., whenever the resolution of the input image changes.<br>
479  * The tracker is simply reset to a state before the first call of determinePoses().
480  */
481  void reset();
482 
483  /**
484  * Converts a known camera pose determined by this pattern tracker to a corresponding camera pose based on a difference camera profile.
485  * Beware: The conversion is an approximation only and does not reflect a mathematic perfect solution.
486  * @param newCamera The new camera profile for which the new pose will be calculated, must be valid
487  * @param referenceCamera The camera profile for which the known (reference) pose has been determined by this pattern tracker, must be valid
488  * @param referencePose The known (reference) pose which will be converted based on the new camera profile, must be valid
489  * @param newPose The resulting new pose matching with the new camera profile
490  * @return True, if succeeded
491  */
492  static bool convertPoseForCamera(const PinholeCamera& newCamera, const PinholeCamera& referenceCamera, const HomogenousMatrix4& referencePose, HomogenousMatrix4& newPose);
493 
494  protected:
495 
496  /**
497  * Computes the maximum allowed time between recognition attempts, which may depend on whether or not any targets are currently being tracked.
498  * @return Maximum allowed duration in seconds, with range [0, infinity)
499  */
500  inline double maximumDurationBetweenRecognitionAttempts() const;
501 
502  /**
503  * Determines the 6DOF tracking for a given frame.
504  * @param allowRecognition If false, skip feature extraction and matching for this frame
505  * @param yFrame The 8 bit grayscale frame (with Y8 pixel format) to be used for tracking, must be valid
506  * @param pinholeCamera The pinhole camera object defining the projection, with same dimension as the given frame
507  * @param previousCamera_R_camera Optional relative orientation between the previous frame and the current frame, if known
508  * @param worker Optional worker object
509  * @return True, if succeeded
510  */
511  bool determinePoses(const bool allowRecognition, const Frame& yFrame, const PinholeCamera& pinholeCamera, const Quaternion& previousCamera_R_camera = Quaternion(false), Worker* worker = nullptr);
512 
513  /**
514  * Determines the 6DOF tracking for a given frame which has been downsampled.
515  * @param allowRecognition If false, skip feature extraction and matching for this frame
516  * @param yFrame The 8 bit grayscale frame (with Y8 pixel format) to be used for tracking, must be valid
517  * @param pinholeCamera The pinhole camera object defining the projection, with same dimension as the given frame
518  * @param previousCamera_R_camera Optional relative orientation between the previous frame and the current frame, if known
519  * @param worker Optional worker object
520  * @return True, if succeeded
521  */
522  bool determinePosesWithDownsampledResolution(const bool allowRecognition, const Frame& yFrame, const PinholeCamera& pinholeCamera, const Quaternion& previousCamera_R_camera = Quaternion(false), Worker* worker = nullptr);
523 
524  /**
525  * Determines the 6DOF poses for the registered patterns without any a-priori information.
526  * @param pinholeCamera The pinhole camera object associated with the frame
527  * @param yFrame The current camera frame with grayscale pixel format (Y8), must be valid
528  * @param currentFramePyramid The frame pyramid of the current frame
529  * @param previousCamera_R_camera Optional relative orientation between the previous frame and the current frame, if known
530  * @param worker Optional worker object
531  * @return True, if succeeded
532  */
533  bool determinePosesWithoutKnowledge(const PinholeCamera& pinholeCamera, const Frame& yFrame, const CV::FramePyramid& currentFramePyramid, const Quaternion& previousCamera_R_camera = Quaternion(false), Worker* worker = nullptr);
534 
535  /**
536  * Counts the number of currently visible pattern.
537  * @return The number of visible pattern
538  */
539  inline unsigned int internalNumberVisiblePattern() const;
540 
541  /**
542  * Returns the maximal number of pattern that can be tracked concurrently within one frame.
543  * This function is an internal helper function providing the number of pattern that are allowed to be visible concurrently.
544  * @return The number of pattern that can be tracked concurrently, with range [1, numberPattern()]
545  */
546  inline unsigned int internalMaxConcurrentlyVisiblePattern() const;
547 
548  /**
549  * Determine the camera pose for the current camera frame and for a given pattern by application of 2D/3D feature points correspondences determined for the previous camera frame.
550  * @param pinholeCamera The pinhole camera profile to be used, must be valid
551  * @param previousFramePyramid The frame pyramid of the previous frame, must be valid
552  * @param currentFramePyramid The frame pyramid of the current camera frame, with same frame type and number of layers as 'previousFramePyramid', must be valid
553  * @param pattern The tracking pattern object which is needs to be re-found (re-tracked) in the current camera frame
554  * @param previousCamera_R_camera Optional relative orientation between the previous frame and the current frame, if known
555  * @param worker Optional worker object to distribute the computation
556  * @return True, if the pattern could be tracked reliably
557  */
558  static bool determinePoseWithPreviousCorrespondences(const PinholeCamera& pinholeCamera, const CV::FramePyramid& previousFramePyramid, const CV::FramePyramid& currentFramePyramid, Pattern& pattern, const Quaternion& previousCamera_R_camera = Quaternion(false), Worker* worker = nullptr);
559 
560  /**
561  * Determines the camera pose for extreme camera motion for a given pattern for which a pose guess is known.
562  * The resulting pose will not be free of drift errors as the pose is determine between successive camera frames only.
563  * However, the resulting pose will be better than no pose (in most situations).
564  * @param pinholeCamera The pinhole camera profile to be used, must be valid
565  * @param previousFramePyramid The frame pyramid of the previous frame, must be valid
566  * @param currentFramePyramid The frame pyramid of the current camera frame, with same frame type and number of layers as 'previousFramePyramid', must be valid
567  * @param pattern The tracking pattern object which is needs to be re-found (re-tracked) in the current camera frame
568  * @param previousCamera_R_camera Optional relative orientation between the previous frame and the current frame, if known
569  * @param worker Optional worker object to distribute the computation
570  * @return True, if the pattern could be tracked with a drift-error-based pose
571  */
572  static bool determinePoseWithDriftErrors(const PinholeCamera& pinholeCamera, const CV::FramePyramid& previousFramePyramid, const CV::FramePyramid& currentFramePyramid, Pattern& pattern, const Quaternion& previousCamera_R_camera = Quaternion(false), Worker* worker = nullptr);
573 
574  /**
575  * Tracks a set of 2D/3D points correspondences from the previous frame to the current frame (in a specified pyramid layer).
576  * @param pinholeCamera The pinhole camera profile to be used
577  * @param previousFramePyramid The frame pyramid of the previous frame
578  * @param currentFramePyramid The frame pyramid of the current frame
579  * @param trackingLayer The pyramid layer which is used for tracking
580  * @param previousPose The camera pose for the previous frame
581  * @param previousObjectPoints The 3D object points which have been used to determine the previous pose
582  * @param previousImagePoints The 2D image points which have been used to determine the previous pose, each points has a corresponding 3D object points, the points are defined in the finest pyramid layer
583  * @param roughPose Resulting pose determined for tracked points in the specified pyramid layer 'trackingLayer'
584  * @param worker Optional worker object to distribute the computation
585  * @param numberFeatures The number of feature points which will be used for tracking, with range [3, infinity)
586  * @param maxError The maximal square error between bidirectional tracked feature points
587  * @return True, if succeeded
588  */
589  static bool trackFrame2FrameHierarchy(const PinholeCamera& pinholeCamera, const CV::FramePyramid& previousFramePyramid, const CV::FramePyramid& currentFramePyramid, const unsigned int trackingLayer, const HomogenousMatrix4& previousPose, const Vectors3& previousObjectPoints, const Vectors2& previousImagePoints, HomogenousMatrix4& roughPose, Worker* worker = nullptr, const unsigned int numberFeatures = 20u, const Scalar maxError = Scalar(0.9 * 0.9));
590 
591  /**
592  * Tracks a set of 2D/3D points correspondences from the previous frame to the current frame.
593  * @param pinholeCamera The pinhole camera profile to be used
594  * @param previousFramePyramid The frame pyramid of the previous frame
595  * @param currentFramePyramid The frame pyramid of the current frame
596  * @param previousPose The camera pose for the previous frame
597  * @param previousObjectPoints The 3D object points which have been used to determine the previous pose, and resulting 3D object points which could be tracked
598  * @param previousImagePoints The 2D image points which have been used to determine the previous pose, each points has a corresponding 3D object points, and resulting 2D image points which could be tracked
599  * @param currentImagePoints The resulting 2D image points which have been tracked in the current frame
600  * @param currentPose The resulting current camera pose
601  * @param roughCurrentPose Optional rough current camera pose which can be used to improve the tracking performance
602  * @param worker Optional worker object to distribute the computation
603  * @return True, if succeeded
604  */
605  static bool trackFrame2Frame(const PinholeCamera& pinholeCamera, const CV::FramePyramid& previousFramePyramid, const CV::FramePyramid& currentFramePyramid, const HomogenousMatrix4& previousPose, Vectors3& previousObjectPoints, Vectors2& previousImagePoints, Vectors2& currentImagePoints, HomogenousMatrix4& currentPose, const HomogenousMatrix4& roughCurrentPose = HomogenousMatrix4(false), Worker* worker = nullptr);
606 
607  /**
608  * Optimizes a given camera pose by rectification of the current camera frame so that it matches with the original tracking pattern.
609  * @param pinholeCamera The pinhole camera profile to be used
610  * @param currentFramePyramid The frame pyramid of the current camera frame, with pixel format FORMAT_Y8
611  * @param roughPose The rough camera pose which will be optimized
612  * @param pattern The tracking pattern object which is needs to be re-found (re-tracked) in the current camera frame
613  * @param optimizedPose Resulting optimized camera pose
614  * @param worker Optional worker object to distribute the computation
615  * @param occlusionArray Optional resulting occlusion array specifying which parts of the rectified camera frame matched with the tracking pattern and which parts are expected to be occluded by different objects
616  * @return True, if the given rough pose could be optimized
617  */
618  static bool optimizePoseByRectification(const PinholeCamera& pinholeCamera, const CV::FramePyramid& currentFramePyramid, const HomogenousMatrix4& roughPose, const Pattern& pattern, HomogenousMatrix4& optimizedPose, Worker* worker = nullptr, Geometry::SpatialDistribution::OccupancyArray* occlusionArray = nullptr);
619 
620  /**
621  * Returns a sub region based on a set of given 2D triangles.
622  * Due to numerical instability, triangles may be invalid in extreme tracking situations (especially if 32 bit floating point values are used).<br>
623  * Thus, this function uses a backup sub region which is used whenever one triangle is invalid.<br>
624  * The backup sub region is defined by width and height, with origin at (0, 0).
625  * @param triangles The triangles defining the sub region, at least one triangle
626  * @param backupWidth The width of the backup sub region, with range (0, infinity)
627  * @param backupHeight The height of the backup sub region, with range (0, infinity)
628  * @return The resulting sub region
629  */
630  static CV::SubRegion triangles2subRegion(const Triangles2& triangles, const unsigned int backupWidth, const unsigned int backupHeight);
631 
632  /**
633  * Determines and describes feature points in an image.
634  * @param camera The camera profile defining the projection, must be valid
635  * @param yFrame The frame in which the feature points will be detected, with pixel format FORMAT_Y8, must be valid
636  * @param imagePoints The resulting 2D image points located in the image
637  * @param imagePointDescriptors The resulting descriptors, one for each image point
638  * @param harrisCornerThreshold The minimal strength value of a Harris corner to be used as feature point, with range [0, infinity)
639  * @param worker Optional worker object to distribute the computation
640  */
641  static bool detectAndDescribeFeatures(const SharedAnyCamera& camera, const Frame& yFrame, Vectors2& imagePoints, Descriptors& imagePointDescriptors, const unsigned int harrisCornerThreshold = 20u, Worker* worker = nullptr);
642 
643  /**
644  * Simple helper function to determine the distance between two feature descriptors.
645  * @param descriptorA The first descriptor
646  * @param descriptorB The second descriptor
647  * @return The distance between both descriptors
648  */
649  static OCEAN_FORCE_INLINE unsigned int determineDescriptorDistance(const Descriptor& descriptorA, const Descriptor& descriptorB);
650 
651  protected:
652 
653  /// Set of options for this tracker.
655 
656  /// Frame pyramid of the current tracking frame.
658 
659  /// Frame pyramid of the previous tracking frame.
661 
662  /// The map holding all registered pattern object.
664 
665  /// Optional absolute orientation for the previous camera frame (as provided from outside this tracker, e.g., via an IMU sensor).
666  Quaternion world_R_previousCamera_ = Quaternion(false);
667 
668  /// Random generator object.
670 
671  /// A counter providing unique pattern ids.
672  unsigned int patternMapIdCounter_ = 0u;
673 
674  /// Tracker lock object.
675  mutable Lock lock_;
676 
677  /// The timestamp of the previous frame.
679 
680  /// The last timestamp at which we started an attempt to recognize a new pattern (this timestamp is prior to feature extraction).
682 
683  /// The id of the pattern that has been tried to recognized last.
684  unsigned int lastRecognitionPatternId_ = 0u;
685 };
686 
688 {
689  return objectPoints_;
690 }
691 
693 {
694  return descriptors_;
695 }
696 
697 inline const PatternTrackerCore6DOF::FeatureMap& PatternTrackerCore6DOF::Pattern::featureMap() const
698 {
699  return featureMap_;
700 }
701 
702 inline const CV::FramePyramid& PatternTrackerCore6DOF::Pattern::pyramid() const
703 {
704  return patternPyramid_;
705 }
706 
707 inline const Vector2& PatternTrackerCore6DOF::Pattern::dimension() const
708 {
709  return dimension_;
710 }
711 
712 inline Vector3 PatternTrackerCore6DOF::Pattern::corner0() const
713 {
714  ocean_assert(isValid());
715  return Vector3(0, 0, 0);
716 }
717 
718 inline Vector3 PatternTrackerCore6DOF::Pattern::corner1() const
719 {
720  ocean_assert(isValid());
721  return Vector3(0, 0, dimension_.y());
722 }
723 
724 inline Vector3 PatternTrackerCore6DOF::Pattern::corner2() const
725 {
726  ocean_assert(isValid());
727  return Vector3(dimension_.x(), 0, dimension_.y());
728 }
729 
730 inline Vector3 PatternTrackerCore6DOF::Pattern::corner3() const
731 {
732  ocean_assert(isValid());
733  return Vector3(dimension_.x(), 0, 0);
734 }
735 
736 inline Triangles3 PatternTrackerCore6DOF::Pattern::triangles3() const
737 {
738  Triangles3 result(2);
739  result[0] = Triangle3(corner0(), corner1(), corner2());
740  result[1] = Triangle3(corner0(), corner2(), corner3());
741 
742  return result;
743 }
744 
745 inline Triangles2 PatternTrackerCore6DOF::Pattern::triangles2(const PinholeCamera& pinholeCamera) const
746 {
747  ocean_assert(world_T_previousCamera_.isValid());
748 
749  return triangles2(pinholeCamera, world_T_previousCamera_);
750 }
751 
752 inline Triangles2 PatternTrackerCore6DOF::Pattern::triangles2(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& pose) const
753 {
754  ocean_assert(pose.isValid());
755 
756  Triangles2 triangles;
757 
758  triangles =
759  {
760  pinholeCamera.projectToImage<true>(pose, Triangle3(corner0(), corner1(), corner2()), pinholeCamera.hasDistortionParameters()),
761  pinholeCamera.projectToImage<true>(pose, Triangle3(corner0(), corner2(), corner3()), pinholeCamera.hasDistortionParameters())
762  };
763 
764  return triangles;
765 }
766 
767 inline const HomogenousMatrix4& PatternTrackerCore6DOF::Pattern::previousPose() const
768 {
769  return world_T_previousCamera_;
770 }
771 
772 inline HomogenousMatrix4& PatternTrackerCore6DOF::Pattern::previousPose()
773 {
774  return world_T_previousCamera_;
775 }
776 
777 inline const Vectors3& PatternTrackerCore6DOF::Pattern::objectPoints() const
778 {
779  return objectPoints_;
780 }
781 
782 inline Vectors3& PatternTrackerCore6DOF::Pattern::objectPoints()
783 {
784  return objectPoints_;
785 }
786 
787 inline const Vectors2& PatternTrackerCore6DOF::Pattern::imagePoints() const
788 {
789  return imagePoints_;
790 }
791 
792 inline Vectors2& PatternTrackerCore6DOF::Pattern::imagePoints()
793 {
794  return imagePoints_;
795 }
796 
797 inline const Vectors2& PatternTrackerCore6DOF::Pattern::referencePoints(const unsigned int layer) const
798 {
799  ocean_assert(layer < patternPyramid_.layers() && layer < pyramidReferencePoints_.size());
800  return pyramidReferencePoints_[layer];
801 }
802 
803 inline unsigned int PatternTrackerCore6DOF::Pattern::layers() const
804 {
805  return (unsigned int)(pyramidReferencePoints_.size());
806 }
807 
808 inline bool PatternTrackerCore6DOF::Pattern::hasPoseGuess(HomogenousMatrix4& poseGuess, const double maximalAge)
809 {
810  ocean_assert(maximalAge >= 0.0 && maximalAge <= 2.0);
811 
812  if (world_T_guessCamera_.isValid() && NumericD::abs(double(Timestamp(true) - poseGuessTimestamp_)) <= maximalAge)
813  {
814  poseGuess = world_T_guessCamera_;
815  return true;
816  }
817 
818  return false;
819 }
820 
821 inline const HomogenousMatrix4& PatternTrackerCore6DOF::Pattern::poseGuess(Timestamp* timestamp)
822 {
823  if (timestamp)
824  {
825  *timestamp = poseGuessTimestamp_;
826  }
827 
828  return world_T_guessCamera_;
829 }
830 
831 inline void PatternTrackerCore6DOF::Pattern::setPoseGuess(const HomogenousMatrix4& pose, const Timestamp& timestamp)
832 {
833  world_T_guessCamera_ = pose;
834  poseGuessTimestamp_ = timestamp;
835 }
836 
837 inline bool PatternTrackerCore6DOF::Pattern::isValid() const
838 {
839  return patternPyramid_.isValid();
840 }
841 
842 inline PatternTrackerCore6DOF::Pattern::operator bool() const
843 {
844  return isValid();
845 }
846 
847 inline unsigned int PatternTrackerCore6DOF::numberPattern() const
848 {
849  const ScopedLock scopedLock(lock_);
850 
851  return (unsigned int)(patternMap_.size());
852 }
853 
855 {
856  const ScopedLock scopedLock(lock_);
857 
859 }
860 
862 {
863  const ScopedLock scopedLock(lock_);
864 
866 }
867 
869 {
871 }
872 
874 {
875  unsigned int number = 0u;
876 
877  for (PatternMap::const_iterator i = patternMap_.begin(); i != patternMap_.end(); ++i)
878  {
879  if (i->second.previousPose().isValid())
880  {
881  number++;
882  }
883  }
884 
885  return number;
886 }
887 
889 {
891  {
892  return (unsigned int)patternMap_.size();
893  }
894  else
895  {
896  return min(options_.maxConcurrentlyVisiblePattern_, (unsigned int)(patternMap_.size()));
897  }
898 }
899 
900 OCEAN_FORCE_INLINE unsigned int PatternTrackerCore6DOF::determineDescriptorDistance(const Descriptor& descriptorA, const Descriptor& descriptorB)
901 {
902  return descriptorA.distance(descriptorB);
903 }
904 
905 }
906 
907 }
908 
909 }
910 
911 #endif // META_OCEAN_TRACKING_PATTERN_PATTERN_TRACKER_CORE_6DOF_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:1792
This class implements an occupancy array.
Definition: SpatialDistribution.h:370
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
This class implements a recursive lock object.
Definition: Lock.h:31
static T abs(const T value)
Returns the absolute value of a given value.
Definition: Numeric.h:1220
bool hasDistortionParameters() const
Returns whether this camera object has specified distortion parameters.
Definition: PinholeCamera.h:1293
VectorT2< T > projectToImage(const HomogenousMatrixT4< T > &world_T_camera, const VectorT3< T > &worldObjectPoint, const bool distortImagePoint, const T zoom=T(1)) const
Projects a 3D object point to the 2D image plane of the camera by a given camera pose.
Definition: PinholeCamera.h:1772
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
This class implements a timestamp.
Definition: Timestamp.h:36
bool isValid() const
Returns whether the timestamp holds a valid time.
Definition: Timestamp.h:303
Definition of a lightweight 3D feature map holding 3D object points and descriptors for all features ...
Definition: PatternTrackerCore6DOF.h:110
FeatureMap(const uint8_t *yFrame, const unsigned int width, const unsigned int height, const unsigned int yFramePaddingElements, const Vector2 &dimension, Worker *worker=nullptr)
Creates a new feature map for a planar 3D object (an image placed in the x-z plane).
Descriptors descriptors_
The descriptors of all features, one for each 3D object point location.
Definition: PatternTrackerCore6DOF.h:147
const Vectors3 & objectPoints() const
Returns the 3D object points of all map features.
Definition: PatternTrackerCore6DOF.h:687
Vectors3 objectPoints_
The 3D locations of all features in this map.
Definition: PatternTrackerCore6DOF.h:144
const Descriptors & descriptors() const
Returns the descriptor associated with the 3D object points of this map.
Definition: PatternTrackerCore6DOF.h:692
Set of configurable parameters for the tracker.
Definition: PatternTrackerCore6DOF.h:56
unsigned int maxConcurrentlyVisiblePattern_
The maximal number of patterns that can be visible concurrently, with range [1, infinity)....
Definition: PatternTrackerCore6DOF.h:67
double recognitionCadenceWithoutTrackedPatterns_
Time in seconds to wait between recognition attempts when no patterns are currently being tracked.
Definition: PatternTrackerCore6DOF.h:76
double recognitionCadenceWithTrackedPatterns_
Time in seconds to wait between recognition attempts when at least one pattern is currently being tra...
Definition: PatternTrackerCore6DOF.h:73
This class stores the information necessary for one tracking pattern.
Definition: PatternTrackerCore6DOF.h:154
Pattern()=default
Creates a new invalid pattern object.
std::vector< Vectors2 > PointLayers
Definition of a vector holding 2D feature positions.
Definition: PatternTrackerCore6DOF.h:160
void reset()
Resets the internal recognition states of this pattern while the actual feature map is untouched.
Pattern(const uint8_t *yFrame, const unsigned int width, const unsigned int height, const unsigned int yFramePaddingElements, const Vector2 &dimension, Worker *worker=nullptr)
Creates a new pattern object by a given frame and pattern dimension.
Timestamp poseGuessTimestamp_
The timestamp of the rough camera pose.
Definition: PatternTrackerCore6DOF.h:365
CV::FramePyramid patternPyramid_
The frame pyramid of the image specifying the pattern.
Definition: PatternTrackerCore6DOF.h:344
Vectors3 objectPoints_
The 3D object points which have been used in the previous (or current) tracking iteration.
Definition: PatternTrackerCore6DOF.h:353
Vectors2 imagePoints_
The 2D image points which have been used in the previous (or current) tracking iteration.
Definition: PatternTrackerCore6DOF.h:356
PointLayers pyramidReferencePoints_
The point pyramid of the pattern image storing reference feature points for individual pattern resolu...
Definition: PatternTrackerCore6DOF.h:359
FeatureMap featureMap_
The feature map of this pattern.
Definition: PatternTrackerCore6DOF.h:341
This class implements the core of the 6DOF feature tracker for planar patterns.
Definition: PatternTrackerCore6DOF.h:49
bool determinePosesWithoutKnowledge(const PinholeCamera &pinholeCamera, const Frame &yFrame, const CV::FramePyramid &currentFramePyramid, const Quaternion &previousCamera_R_camera=Quaternion(false), Worker *worker=nullptr)
Determines the 6DOF poses for the registered patterns without any a-priori information.
~PatternTrackerCore6DOF()
Destructs a feature tracker object.
bool removePatterns()
Removes all patterns from this tracker.
CV::Detector::FREAKDescriptor32 Descriptor
Definition of the descriptor to be used.
Definition: PatternTrackerCore6DOF.h:96
static bool optimizePoseByRectification(const PinholeCamera &pinholeCamera, const CV::FramePyramid &currentFramePyramid, const HomogenousMatrix4 &roughPose, const Pattern &pattern, HomogenousMatrix4 &optimizedPose, Worker *worker=nullptr, Geometry::SpatialDistribution::OccupancyArray *occlusionArray=nullptr)
Optimizes a given camera pose by rectification of the current camera frame so that it matches with th...
Timestamp lastRecognitionAttemptTimestamp_
The last timestamp at which we started an attempt to recognize a new pattern (this timestamp is prior...
Definition: PatternTrackerCore6DOF.h:681
Options options_
Set of options for this tracker.
Definition: PatternTrackerCore6DOF.h:654
CV::FramePyramid currentFramePyramid_
Frame pyramid of the current tracking frame.
Definition: PatternTrackerCore6DOF.h:657
Timestamp timestampPreviousFrame_
The timestamp of the previous frame.
Definition: PatternTrackerCore6DOF.h:678
unsigned int addPattern(const uint8_t *yFrame, const unsigned int width, const unsigned int height, const unsigned int yFramePaddingElements, const Vector2 &dimension, Worker *worker=nullptr)
Adds a new 2D tracking pattern (an image) to the tracker.
void setMaxConcurrentlyVisiblePattern(const unsigned int maxConcurrentlyVisiblePattern)
Sets the maximal number of pattern that can be tracked concurrently within one frame.
Definition: PatternTrackerCore6DOF.h:861
unsigned int addPattern(const std::string &filename, const Vector2 &dimension, Worker *worker=nullptr)
Adds a new 2D tracking pattern (an image) to the tracker.
bool recentFeatureCorrespondences(const unsigned int patternId, Vectors2 &imagePoints, Vectors3 &objectPoints, HomogenousMatrix4 *pattern_T_camera=nullptr) const
Returns the latest 2D/3D correspondences for a pattern which has been used to determine the camera po...
std::map< unsigned int, Pattern > PatternMap
Definition of a map holding pattern objects.
Definition: PatternTrackerCore6DOF.h:371
CV::Detector::FREAKDescriptors32 Descriptors
Definition of the descriptors to be used.
Definition: PatternTrackerCore6DOF.h:101
RandomGenerator randomGenerator_
Random generator object.
Definition: PatternTrackerCore6DOF.h:669
static OCEAN_FORCE_INLINE unsigned int determineDescriptorDistance(const Descriptor &descriptorA, const Descriptor &descriptorB)
Simple helper function to determine the distance between two feature descriptors.
Definition: PatternTrackerCore6DOF.h:900
unsigned int internalNumberVisiblePattern() const
Counts the number of currently visible pattern.
Definition: PatternTrackerCore6DOF.h:873
CV::FramePyramid previousFramePyramid_
Frame pyramid of the previous tracking frame.
Definition: PatternTrackerCore6DOF.h:660
static bool detectAndDescribeFeatures(const SharedAnyCamera &camera, const Frame &yFrame, Vectors2 &imagePoints, Descriptors &imagePointDescriptors, const unsigned int harrisCornerThreshold=20u, Worker *worker=nullptr)
Determines and describes feature points in an image.
static CV::SubRegion triangles2subRegion(const Triangles2 &triangles, const unsigned int backupWidth, const unsigned int backupHeight)
Returns a sub region based on a set of given 2D triangles.
void reset()
Resets the tracker's states but keeps all registered pattern.
static bool convertPoseForCamera(const PinholeCamera &newCamera, const PinholeCamera &referenceCamera, const HomogenousMatrix4 &referencePose, HomogenousMatrix4 &newPose)
Converts a known camera pose determined by this pattern tracker to a corresponding camera pose based ...
static bool determinePoseWithDriftErrors(const PinholeCamera &pinholeCamera, const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid &currentFramePyramid, Pattern &pattern, const Quaternion &previousCamera_R_camera=Quaternion(false), Worker *worker=nullptr)
Determines the camera pose for extreme camera motion for a given pattern for which a pose guess is kn...
bool determinePoses(const bool allowRecognition, const Frame &yFrame, const PinholeCamera &pinholeCamera, const Quaternion &previousCamera_R_camera=Quaternion(false), Worker *worker=nullptr)
Determines the 6DOF tracking for a given frame.
bool removePattern(const unsigned int patternId)
Removes a pattern from this tracker.
Lock lock_
Tracker lock object.
Definition: PatternTrackerCore6DOF.h:675
unsigned int numberPattern() const
Returns the number of registered/added pattern.
Definition: PatternTrackerCore6DOF.h:847
unsigned int internalMaxConcurrentlyVisiblePattern() const
Returns the maximal number of pattern that can be tracked concurrently within one frame.
Definition: PatternTrackerCore6DOF.h:888
bool determinePoses(const uint8_t *yFrame, const PinholeCamera &pinholeCamera, const unsigned int yFramePaddingElements, const bool frameIsUndistorted, const Timestamp &timestamp, VisualTracker::TransformationSamples &transformations, const Quaternion &world_R_camera=Quaternion(false), Worker *worker=nullptr)
Executes the 6DOF tracking for a given frame.
static bool trackFrame2FrameHierarchy(const PinholeCamera &pinholeCamera, const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid &currentFramePyramid, const unsigned int trackingLayer, const HomogenousMatrix4 &previousPose, const Vectors3 &previousObjectPoints, const Vectors2 &previousImagePoints, HomogenousMatrix4 &roughPose, Worker *worker=nullptr, const unsigned int numberFeatures=20u, const Scalar maxError=Scalar(0.9 *0.9))
Tracks a set of 2D/3D points correspondences from the previous frame to the current frame (in a speci...
unsigned int maxConcurrentlyVisiblePattern() const
Returns the maximal number of pattern that can be tracked concurrently within one frame.
Definition: PatternTrackerCore6DOF.h:854
PatternMap patternMap_
The map holding all registered pattern object.
Definition: PatternTrackerCore6DOF.h:663
double maximumDurationBetweenRecognitionAttempts() const
Computes the maximum allowed time between recognition attempts, which may depend on whether or not an...
Definition: PatternTrackerCore6DOF.h:868
bool determinePosesWithDownsampledResolution(const bool allowRecognition, const Frame &yFrame, const PinholeCamera &pinholeCamera, const Quaternion &previousCamera_R_camera=Quaternion(false), Worker *worker=nullptr)
Determines the 6DOF tracking for a given frame which has been downsampled.
PatternTrackerCore6DOF(const Options &options=Options())
Creates a new feature tracker object.
static bool determinePoseWithPreviousCorrespondences(const PinholeCamera &pinholeCamera, const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid &currentFramePyramid, Pattern &pattern, const Quaternion &previousCamera_R_camera=Quaternion(false), Worker *worker=nullptr)
Determine the camera pose for the current camera frame and for a given pattern by application of 2D/3...
static bool trackFrame2Frame(const PinholeCamera &pinholeCamera, const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid &currentFramePyramid, const HomogenousMatrix4 &previousPose, Vectors3 &previousObjectPoints, Vectors2 &previousImagePoints, Vectors2 &currentImagePoints, HomogenousMatrix4 &currentPose, const HomogenousMatrix4 &roughCurrentPose=HomogenousMatrix4(false), Worker *worker=nullptr)
Tracks a set of 2D/3D points correspondences from the previous frame to the current frame.
std::vector< TransformationSample > TransformationSamples
Definition of a vector holding a transformation sample object.
Definition: tracking/VisualTracker.h:98
This class implements a 3D triangle.
Definition: Triangle3.h:80
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
QuaternionT< Scalar > Quaternion
Definition of the Quaternion object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sin...
Definition: Quaternion.h:33
TriangleT3< Scalar > Triangle3
Definition of the Triangle3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition: Triangle3.h:21
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::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition: AnyCamera.h:60
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition: Vector3.h:22
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
std::vector< Triangle3 > Triangles3
Definition of a vector holding 3D triangles.
Definition: Triangle3.h:57
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition: HomogenousMatrix4.h:37
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition: Vector3.h:65
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
std::vector< FREAKDescriptor32 > FREAKDescriptors32
Vector of 32-bytes long FREAK descriptors.
Definition: FREAKDescriptor.h:69
FREAKDescriptorT< 32 > FREAKDescriptor32
Typedef for the 32-bytes long FREAK descriptor.
Definition: FREAKDescriptor.h:66
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15