8 #ifndef META_OCEAN_TRACKING_OFFLINE_PLANAR_RECTANGLE_TRACKER_PLANAR_H
9 #define META_OCEAN_TRACKING_OFFLINE_PLANAR_RECTANGLE_TRACKER_PLANAR_H
32 class PlanarRectangleTracker;
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);
305 inline 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:37
unsigned int layers() const
Returns the number of layers this pyramid holds.
Definition: FramePyramid.h:761
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
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition: Frame.h:30
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
PinholeCamera camera_
The camera object of this tracker.
Definition: FrameTracker.h:354
This component implements a plane tracker that uses an already known plane to create camera poses.
Definition: PlanarRectangleTracker.h:72
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.
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
ShiftVector< Geometry::NonLinearOptimizationPlane::ImagePointsPair > ImagePointsPairs
Definition of a shift vector holding image point pairs.
Definition: PlanarRectangleTracker.h:59
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
ShiftVector< SquareMatrix3 > Homographies
Definition of a shift vector holding homographies.
Definition: PlanarRectangleTracker.h:54
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.
bool applyFrameTracking(const FrameType &frameType) override
Frame tracker run function.
PlanarRectangleTracker()
Creates a new tracker object.
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...
This class implements the abstract base class for all plane trackers.
Definition: PlaneTracker.h:42
Plane3 plane_
The plane of this tracker.
Definition: PlaneTracker.h:80
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< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
std::vector< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition: Tracking.h:55
SmartObjectRef< PlanarRectangleTracker, OfflineTracker > PlanarRectangleTrackerRef
Definition of an object reference holding a PlanarRectangleTracker object.
Definition: PlanarRectangleTracker.h:32
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15