8#ifndef META_OCEAN_TRACKING_OFFLINE_PLANAR_RECTANGLE_TRACKER_PLANAR_H
9#define META_OCEAN_TRACKING_OFFLINE_PLANAR_RECTANGLE_TRACKER_PLANAR_H
62 class CameraPosesData;
65 class DistortionCameraPosesData;
97 IterationResult onFrame(
const unsigned int previousIndex,
const unsigned int currentIndex,
const unsigned int iteration,
const unsigned int maximalIterations)
override;
103 bool onStart(
const unsigned int lowerFrameIndex,
const unsigned int initialFrameIndex,
const unsigned int upperFrameIndex)
override;
109 bool onStop(
const unsigned int lowerFrameIndex,
const unsigned int initialFrameIndex,
const unsigned int upperFrameIndex)
override;
129 inline size_t frame2framePose(
const CV::FramePyramid& previousFramePyramid,
const CV::FramePyramid& currentFramePyramid,
const CV::SubRegion& previousSubRegion,
const HomogenousMatrix4& previousPose,
HomogenousMatrix4& currentPose,
const Scalar maximalSqrError,
const unsigned int horizontalBins,
const unsigned int verticalBins,
const unsigned int strength,
Worker* worker =
nullptr,
const unsigned int trackingLayers = 1u,
Vectors2* previousImagePoints =
nullptr,
Vectors2* currentImagePoints =
nullptr);
305inline size_t PlanarRectangleTracker::PlaneTrackerComponent::frame2framePose(
const CV::FramePyramid& previousFramePyramid,
const CV::FramePyramid& currentFramePyramid,
const CV::SubRegion& previousSubRegion,
const HomogenousMatrix4& previousPose,
HomogenousMatrix4& currentPose,
const Scalar maximalSqrError,
const unsigned int horizontalBins,
const unsigned int verticalBins,
const unsigned int strength,
Worker* worker,
const unsigned int trackingLayers,
Vectors2* previousImagePoints,
Vectors2* currentImagePoints)
307 ocean_assert(previousFramePyramid && currentFramePyramid);
308 ocean_assert(previousFramePyramid.
layers() == currentFramePyramid.
layers());
310 return Frame2FrameTracker::trackPlanarObject<15u>(
camera_, previousFramePyramid, currentFramePyramid, 2u, previousPose,
plane_, previousSubRegion, currentPose, maximalSqrError, horizontalBins, verticalBins, strength, worker, trackingLayers, previousImagePoints, currentImagePoints);
This class implements a frame pyramid.
Definition FramePyramid.h:46
unsigned int layers() const
Returns the number of layers this pyramid holds.
Definition FramePyramid.h:811
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:1969
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
This class implements a vector with shifted elements.
Definition ShiftVector.h:27
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition SmartObjectRef.h:90
static bool trackPlanarObject(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &previousPose, const Plane3 &previousPlane, const Vector2 *previousImagePoints, const Vector2 *nextImagePoints, const size_t correspondences, HomogenousMatrix4 &nextPose)
This function tracks a planar plane or object between two successive frames.
FramePyramidTrackerComponent(FrameTracker &tracker)
Creates a new component object.
IterationResult
Definition of individual results for the component iterations.
Definition FrameTracker.h:62
FrameTracker()=default
Creates a new offline frame tracker object.
virtual OfflinePoses poses() const
Returns the currently determined poses of this tracker.
bool onStart(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override
Component start event function.
const HomogenousMatrix4 & initialPose_
Initial camera pose for the frame index for that the tracking starts.
Definition PlanarRectangleTracker.h:161
OfflinePoses & resultingPoses_
The resulting poses that are tracked in this component.
Definition PlanarRectangleTracker.h:170
bool optimizePose(const Frame ¤tFrame, const HomogenousMatrix4 ¤tPose, HomogenousMatrix4 &optimizedPose, Worker *worker, ImagePoints *validInitialImagePoints, ImagePoints *validCurrentImagePoints, bool *reliableImagePoints=nullptr)
Optimizes an already known pose for the current frame by creating two rectified frames of the trackin...
CV::FramePyramid intermediateRectifiedFramePyramid_
The frame pyramid of the intermediate rectified frame.
Definition PlanarRectangleTracker.h:185
HomogenousMatrix4 initialRectifiedPose_
The camera pose that is used to create the initial rectified frame.
Definition PlanarRectangleTracker.h:179
bool optimizeCamera(PinholeCamera &optimizedCamera, const unsigned int numberFrames)
Optimizes the camera profile for the point correspondences that have been determined during the track...
OfflinePoses poses_
The camera poses that are detected during tracking, one pose for each frame.
Definition PlanarRectangleTracker.h:167
ImagePointsPairs imagePointsPairs_
Pairs of image points that are used to determine the camera pose.
Definition PlanarRectangleTracker.h:188
PinholeCamera initialRectifiedCamera_
The camera profile that is used to create the initial rectified frame.
Definition PlanarRectangleTracker.h:176
bool onStop(const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex) override
Component start event function.
PinholeCamera * resultingOptimizedCamera_
Optional resulting optimized camera profile.
Definition PlanarRectangleTracker.h:191
size_t frame2framePose(const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid ¤tFramePyramid, const CV::SubRegion &previousSubRegion, const HomogenousMatrix4 &previousPose, HomogenousMatrix4 ¤tPose, const Scalar maximalSqrError, const unsigned int horizontalBins, const unsigned int verticalBins, const unsigned int strength, Worker *worker=nullptr, const unsigned int trackingLayers=1u, Vectors2 *previousImagePoints=nullptr, Vectors2 *currentImagePoints=nullptr)
Tracks the camera pose between two successive frames.
Definition PlanarRectangleTracker.h:305
~PlaneTrackerComponent() override
Destructor.
Definition PlanarRectangleTracker.h:300
PlanarRectangleTracker & parent_
The parent tracker invoking this component.
Definition PlanarRectangleTracker.h:155
Frame intermediateRectifiedFrame_
The intermediate rectified frame.
Definition PlanarRectangleTracker.h:182
IterationResult onFrame(const unsigned int previousIndex, const unsigned int currentIndex, const unsigned int iteration, const unsigned int maximalIterations) override
Applies one component step.
CV::FramePyramid initialRectifiedFramePyramid_
The frame pyramid of the rectified initial frame.
Definition PlanarRectangleTracker.h:173
PlaneTrackerComponent(PlanarRectangleTracker &parent, const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &initialPose, const Plane3 &plane, OfflinePoses &resultingPoses, PinholeCamera *resultingOptimizedCamera)
Creates a new plane tracking component object.
const Plane3 plane_
The plane that is applied in this component.
Definition PlanarRectangleTracker.h:164
CV::FramePyramid initialFramePyramid_
Frame pyramid of the initial frame.
Definition PlanarRectangleTracker.h:194
const PinholeCamera camera_
The camera profile that is applied in this component.
Definition PlanarRectangleTracker.h:158
This class implements a tracker that is able to track an rectangle located one a 3D plane.
Definition PlanarRectangleTracker.h:48
const HomogenousMatrix4 initialPose_
The initial pose that is defined for the first frame index, this pose is the default pose: locking to...
Definition PlanarRectangleTracker.h:291
static bool determinePlane(const PinholeCamera &pinholeCamera, const Vector2 rectangleCorners[4], Plane3 &plane)
Determines the plane from four corners of a visible planar rectangle.
CV::SubRegion initialRectangleSubRegion_
The sub-region that represents the initial rectangle corners as two triangles.
Definition PlanarRectangleTracker.h:297
Vector2 initialRectangleCorners_[4]
The user-defined sub-region for the initial tracking frame.
Definition PlanarRectangleTracker.h:294
static bool lookAtTransformation(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &initialPose, const Vector2 rectangleCorners[4], const Plane3 &plane, const Scalar extraBorderPercent, PinholeCamera &lookAtCamera, HomogenousMatrix4 &lookAtPose)
Calculates the transformation (camera pose and camera profile) for the rectangle that the users has s...
void updateCamera(const PinholeCamera &pinholeCamera) override
Updates the camera of this tracker and invokes the corresponding state event(s).
bool setInitialRectangle(const Vector2 rectangleCorners[4])
Sets the four points of a planar rectangle that is visible in the initial camera frame.
bool updateObjectTransformation()
Updates the tracker object transformation using the current camera profile and plane of this tracker.
~PlanarRectangleTracker() override
Destructs a tracker object.
bool trackPlane(const PinholeCamera &pinholeCamera, const Plane3 &plane, const unsigned int lowerFrameIndex, const unsigned int initialFrameIndex, const unsigned int upperFrameIndex, const bool createStateEvents, OfflinePoses &poses, PinholeCamera *optimizedCamera)
Tracks a known plane and can determines the camera poses or/and optimize the camera profile.
ShiftVector< SquareMatrix3 > Homographies
Definition of a shift vector holding homographies.
Definition PlanarRectangleTracker.h:54
bool applyFrameTracking(const FrameType &frameType) override
Frame tracker run function.
PlanarRectangleTracker()
Creates a new tracker object.
ShiftVector< Geometry::NonLinearOptimizationPlane::ImagePointsPair > ImagePointsPairs
Definition of a shift vector holding image point pairs.
Definition PlanarRectangleTracker.h:59
void updatePlane(const Plane3 &plane) override
Updates the plane of this tracker and invokes the corresponding state event(s).
Scalar parallelogramAngle(const PinholeCamera &pinholeCamera, const Plane3 &plane)
Determines the angle difference between a perfect 90 degree rectangular angle and the angle of the pa...
virtual Plane3 plane() const
Returns the plane of this tracker.
PlaneTracker()=default
Creates a new plane tracker object.
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
PlaneT3< Scalar > Plane3
Definition of the Plane3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single ...
Definition Plane3.h:31
PinholeCameraT< Scalar > PinholeCamera
Definition of an pinhole camera object with Scalar precision.
Definition PinholeCamera.h:39
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition Tracking.h:55
ShiftVector< OfflinePose > OfflinePoses
Definition of a shift vector holding offline poses.
Definition OfflinePose.h:33
SmartObjectRef< PlanarRectangleTracker, OfflineTracker > PlanarRectangleTrackerRef
Definition of an object reference holding a PlanarRectangleTracker object.
Definition PlanarRectangleTracker.h:39
Namespace of the Offline Tracker library.
Definition offline/Frame2FrameTracker.h:31
Namespace of the Tracker library.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15