8 #ifndef META_OCEAN_TRACKING_POINT_HOMOGRAPHY_TRACKER_H
9 #define META_OCEAN_TRACKING_POINT_HOMOGRAPHY_TRACKER_H
93 explicit inline operator bool()
const;
116 static constexpr
size_t numberKeyFrames_ = 2;
212 static bool trackPoints(
const CV::FramePyramid& yPreviousFramePyramid,
const CV::FramePyramid& yCurrentFramePyramid,
Vectors2Pyramid& previousPointsPyramid,
Vectors2Pyramid& currentPointsPyramid,
const unsigned int startLayer,
const float maximalOffsetPercent,
Indices32& validTrackedPointIndices,
const SquareMatrix3& roughHomography =
SquareMatrix3(
false),
const unsigned int coarsestLayerRadius = 2u,
const unsigned int subPixelIterations = 2u,
Worker* worker =
nullptr);
235 static HomographyQuality determineHomographyWithPyramid(
const AnyCamera& camera,
const Plane3& plane,
const CV::FramePyramid& yPreviousFramePyramid,
const CV::FramePyramid& yCurrentFramePyramid,
Vectors2Pyramid& previousPointsPyramid,
Vectors2Pyramid& currentPointsPyramid,
Vectors2Pyramid& initialPointsPyramid,
const SquareMatrix3& previousHomography,
const Box2& region,
SquareMatrix3& homography,
HomogenousMatrix4* pose,
const SquareMatrix3& predictedLocalHomography,
const Quaternion& initialCameraOrientation,
const Quaternion& currentCameraOrientation,
RandomGenerator& randomGenerator,
const float explicitMaximalOffsetPercent = -1.0f,
Worker* worker =
nullptr);
318 bool needsReInitialization_ =
false;
323 globalHomography_(false),
324 cameraOrientation_(false)
330 timestamp_(timestamp),
332 pointsPyramid_(pointsPyramid),
333 pyramid_(pyramid, true ),
335 cameraOrientation_(cameraOrientation)
340 inline HomographyTracker::KeyFrame::operator bool()
const
342 ocean_assert(timestamp_.isValid() == pyramid_.isValid());
344 return timestamp_.isValid();
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
This class implements a frame pyramid.
Definition: FramePyramid.h:37
void clear()
Releases the internal frame layers.
Definition: FramePyramid.h:845
This class implements Ocean's image class.
Definition: Frame.h:1792
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
void toNull()
Sets the matrix to a zero matrix.
Definition: SquareMatrix3.h:1311
This class implements a timestamp.
Definition: Timestamp.h:36
This class composes several parameters necessary for a key-frame.
Definition: point/HomographyTracker.h:70
Vectors2Pyramid initialPointsPyramid_
The pyramid of points defined in the initial camera frame, corresponding with points defined in the k...
Definition: point/HomographyTracker.h:101
Vectors2Pyramid pointsPyramid_
The pyramid of points defined in the key-frame (pyramid).
Definition: point/HomographyTracker.h:104
KeyFrame()
Creates a new key frame object.
Definition: point/HomographyTracker.h:321
Quaternion cameraOrientation_
The orientation of the camera when creating the key frame, if known.
Definition: point/HomographyTracker.h:113
Timestamp timestamp_
The timestamp of the key frame.
Definition: point/HomographyTracker.h:98
SquareMatrix3 globalHomography_
The homography transforming points defined in the initial frame to points defined in the key-frame (k...
Definition: point/HomographyTracker.h:110
CV::FramePyramid pyramid_
The frame pyramid of the key-frame which can be used for re-localization.
Definition: point/HomographyTracker.h:107
This class implements a homography-based tracker for planar backgrounds.
Definition: point/HomographyTracker.h:39
HomographyTracker()
Creates a new tracker object.
Definition: point/HomographyTracker.h:347
static bool isRegionVisible(const AnyCamera &camera, const SquareMatrix3 &globalHomography, const Box2 &initialRegion)
Returns whether the region of interest is visible based on the known homography for the current frame...
bool determineHomography(const AnyCamera &camera, const Frame &yFrame, SquareMatrix3 &homography, HomogenousMatrix4 *pose, const Quaternion &cameraOrientation=Quaternion(false), Worker *worker=nullptr)
Determines the homography between the current frame and the initial frame.
bool resetRegion(const AnyCamera &camera, const Box2 ®ion, const Quaternion &cameraOrientation, const Vector3 &planeNormal, HomogenousMatrix4 *pose=nullptr, HomogenousMatrix4 *plane=nullptr)
Sets a new region of interest (or resets an existing region of interest).
static HomographyQuality determineHomographyWithPyramid(const AnyCamera &camera, const Plane3 &plane, const CV::FramePyramid &yPreviousFramePyramid, const CV::FramePyramid &yCurrentFramePyramid, Vectors2Pyramid &previousPointsPyramid, Vectors2Pyramid ¤tPointsPyramid, Vectors2Pyramid &initialPointsPyramid, const SquareMatrix3 &previousHomography, const Box2 ®ion, SquareMatrix3 &homography, HomogenousMatrix4 *pose, const SquareMatrix3 &predictedLocalHomography, const Quaternion &initialCameraOrientation, const Quaternion ¤tCameraOrientation, RandomGenerator &randomGenerator, const float explicitMaximalOffsetPercent=-1.0f, Worker *worker=nullptr)
Determines the homography between two consecutive camera frames based on known feature points located...
bool resetRegion(const AnyCamera &camera, const Box2 ®ion)
Sets a new region of interest (or resets an existing region of interest).
static bool isRegionVisible(const Quaternion &wRi, const Quaternion &wRc, const Scalar maximalAngle=Numeric::deg2rad(50))
Returns whether the region of interest is visible based on a simple angle threshold.
bool needsReInitialization_
True, if the tracker needs to be re-initialized.
Definition: point/HomographyTracker.h:318
static constexpr size_t numberKeyFrames_
Definition: point/HomographyTracker.h:116
Box2 region_
The tracking region (the region of interest) located on the plane, defined in the coordinate system o...
Definition: point/HomographyTracker.h:309
static bool trackPoints(const CV::FramePyramid &yPreviousFramePyramid, const CV::FramePyramid &yCurrentFramePyramid, Vectors2Pyramid &previousPointsPyramid, Vectors2Pyramid ¤tPointsPyramid, const unsigned int startLayer, const float maximalOffsetPercent, Indices32 &validTrackedPointIndices, const SquareMatrix3 &roughHomography=SquareMatrix3(false), const unsigned int coarsestLayerRadius=2u, const unsigned int subPixelIterations=2u, Worker *worker=nullptr)
CV::FramePyramid previousFramePyramid_
The frame pyramid of the previous frame.
Definition: point/HomographyTracker.h:282
SquareMatrix3 globalHomography_
The homography transforming initial image points to current image points: currentImagePoint = globalH...
Definition: point/HomographyTracker.h:303
RandomGenerator randomGenerator_
The random generator object.
Definition: point/HomographyTracker.h:288
void reset()
Resets the homography tracker.
Definition: point/HomographyTracker.h:357
static bool addNewFeaturePointsToPyramidLayer(const CV::FramePyramid &yFramePyramid, Vectors2Pyramid &pointsPyramid, const Triangles2 &layerSubRegionTriangles, const unsigned int layer, const unsigned int featureThreshold=25u, const unsigned int minimalFeatures=30u, const unsigned int maximalFeatures=60u, Worker *worker=nullptr)
Adds new feature points to one specific pyramid layer if the layer does not contain enough feature po...
std::vector< Vectors3 > Vectors3Pyramid
Definition of a pyramid of 3D object points, mainly a vector with object points visible in individual...
Definition: point/HomographyTracker.h:63
KeyFrame keyFrames_[numberKeyFrames_]
The two key frames which will be used during re-initialization.
Definition: point/HomographyTracker.h:315
Vectors2Pyramid initialPointsPyramid_
The image points located in the coordinate system of the initial frame (the frame in which the tracki...
Definition: point/HomographyTracker.h:291
static bool isPosePlausible(const HomogenousMatrix4 ¤tPose, const Quaternion &initialCameraOrientation, const Quaternion ¤tCameraOrientation, const Scalar maximalAngle=Numeric::deg2rad(3))
Returns whether a given 6DOF camera pose if plausible based on e.g., an IMU-based camera orientation.
Plane3 plane_
The 3D plane on which all feature points will be located, if known.
Definition: point/HomographyTracker.h:312
Quaternion previousCameraOrientation_
The orientation of the camera matching with the previous camera frame, defined w.r....
Definition: point/HomographyTracker.h:300
static bool isHomographyPlausible(const SquareMatrix3 &pHi, const SquareMatrix3 &cHi, const Box2 &initialRegion, const Scalar maximalAngleChange=Numeric::deg2rad(5))
Returns whether a given homography is plausible in the context of a previous homography.
HomographyQuality
Definition of homography qualities.
Definition: point/HomographyTracker.h:46
@ HQ_FAILED
The homography is invalid.
Definition: point/HomographyTracker.h:48
@ HQ_MODERATE
The homography has a moderate quality, good enough for visualization, but not good enough to e....
Definition: point/HomographyTracker.h:50
Vectors2Pyramid previousPointsPyramid_
The image points located in 'previousFramePyramid_'.
Definition: point/HomographyTracker.h:294
std::vector< Vectors2 > Vectors2Pyramid
Definition of a pyramid of 2D image points, mainly a vector with image points located in individual p...
Definition: point/HomographyTracker.h:58
Quaternion globalCameraOrientation_
The orientation of the camera frame for the last valid homography 'globalHomography_' (wTl),...
Definition: point/HomographyTracker.h:306
Quaternion initialCameraOrientation_
The orientation of the initial camera frame, (wRi), if known.
Definition: point/HomographyTracker.h:297
static bool addNewFeaturePointsToPyramid(const CV::FramePyramid &yFramePyramid, Vectors2Pyramid &pointsPyramid, Vectors2Pyramid &initialPointsPyramid, const Box2 ®ion, const SquareMatrix3 &homography, const unsigned int minimalFeatures=30u, const unsigned int maximalFeatures=60u, Worker *worker=nullptr)
Adds new feature points to all pyramid layers (at least to all desired layers e.g....
CV::FramePyramid currentFramePyramid_
The frame pyramid of the current frame.
Definition: point/HomographyTracker.h:285
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
QuaternionT< Scalar > Quaternion
Definition of the Quaternion object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sin...
Definition: Quaternion.h:33
SquareMatrixT3< Scalar > SquareMatrix3
Definition of the SquareMatrix3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition: SquareMatrix3.h:35
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
PlaneT3< Scalar > Plane3
Definition of the Plane3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single ...
Definition: Plane3.h:24
BoxT2< Scalar > Box2
Definition of the Box2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single or...
Definition: Box2.h:22
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15