Ocean
Ocean::Tracking::HomographyTracker Class Reference

This class implements a homography tracker able to determine a homography in real-time. More...

Public Member Functions

 HomographyTracker ()=default
 Creates a new homography tracker object and uses 31 as patch size. More...
 
 HomographyTracker (const unsigned int patchSize)
 Creates a new homography tracker object and uses 31 as patch size. More...
 
unsigned int patchSize () const
 Returns the size of the patches which are used for tracking. More...
 
void setPatchSize (const unsigned int size)
 Sets or changes the size of the patches which are used for tracking. More...
 
bool trackPoints (const Frame &currentFrame, const Frame &yPreviousFrame, RandomGenerator &randomGenerator, const Vectors2 &previousPositions, SquareMatrix3 &homography, Worker *worker=nullptr, const Scalar frameBorder=Scalar(10))
 Tracks a group of given image points from the previous frame to the current frame and determines the corresponding homography afterwards. More...
 
void clear ()
 Clears the previous pyramid frame of this tracking object. More...
 

Static Public Member Functions

static bool trackPoints (const Frame &yPreviousFrame, const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid &currentFramePyramid, RandomGenerator &randomGenerator, const Vectors2 &previousPositions, SquareMatrix3 &homography, Worker *worker=nullptr, const unsigned int patchSize=31u)
 Tracks a group of given image points from the previous frame to the current frame and determines the corresponding homography afterwards. More...
 
static Vectors2 transformPoints (const Vectors2 &points, const SquareMatrix3 &transformation)
 Transforms a given set of points to a new set using a given transformation. More...
 

Private Attributes

CV::FramePyramid currentFramePyramid_
 Frame pyramid of the current frame. More...
 
CV::FramePyramid previousFramePyramid_
 Frame pyramid of the previous frame. More...
 
unsigned int patchSize_ = 31u
 The size of the image patches used for tracking, possible values can be [5, 7, 15, 31]. More...
 

Detailed Description

This class implements a homography tracker able to determine a homography in real-time.

The tracker stores the two frame pyramids, one pyramid for the previous frame, one pyramid of the current frame.
For each new camera frame a group of reliable/strong feature points visible in the previous camera frame will be tracked to the new camera frame.
The point correspondences will be used to calculate the homography.
In contrast to HomographyImageAlignmentSparse the HomographyTracker uses explicitly provided image points for the determination of the homography while the HomographyImageAlignmentSparse selects suitable sparse information on its own.

See also
HomographyImageAlignmentSparse.

Constructor & Destructor Documentation

◆ HomographyTracker() [1/2]

Ocean::Tracking::HomographyTracker::HomographyTracker ( )
inlinedefault

Creates a new homography tracker object and uses 31 as patch size.

◆ HomographyTracker() [2/2]

Ocean::Tracking::HomographyTracker::HomographyTracker ( const unsigned int  patchSize)
inlineexplicit

Creates a new homography tracker object and uses 31 as patch size.

Parameters
patchSizeThe size of the patches, possible values can be [5, 7, 15, 31].

Member Function Documentation

◆ clear()

void Ocean::Tracking::HomographyTracker::clear ( )
inline

Clears the previous pyramid frame of this tracking object.

◆ patchSize()

unsigned int Ocean::Tracking::HomographyTracker::patchSize ( ) const
inline

Returns the size of the patches which are used for tracking.

Returns
The patch size currently used, 31 by default

◆ setPatchSize()

void Ocean::Tracking::HomographyTracker::setPatchSize ( const unsigned int  size)
inline

Sets or changes the size of the patches which are used for tracking.

Parameters
sizeThe size of the patches, possible values can be [5, 7, 15, 31].

◆ trackPoints() [1/2]

bool Ocean::Tracking::HomographyTracker::trackPoints ( const Frame currentFrame,
const Frame yPreviousFrame,
RandomGenerator randomGenerator,
const Vectors2 previousPositions,
SquareMatrix3 homography,
Worker worker = nullptr,
const Scalar  frameBorder = Scalar(10) 
)

Tracks a group of given image points from the previous frame to the current frame and determines the corresponding homography afterwards.

In the case this function is invoked for the first time, the current frame is stored for the next function call (as previous frame) and the identity homography is returned.
The resulting homography will transform points defined in the previous frame to points defined in the current frame (pointCurrent = H * pointPrevious).

Parameters
currentFrameThe current frame with pixel format as desired, must be valid
yPreviousFrameThe previous frame as grayscale frame with pixel format FORMAT_Y8, with same frame dimension and pixel origin as the current frame, can be invalid if this function is invoked for the first time
randomGeneratorRandom number generator object
previousPositionsImage points (e.g., string feature points) located in the previous image that will be used for the determination of the homography, may be empty if this function is invoked for the first time
homographyThe resulting homography
workerOptional worker object to distribute the computation
frameBorderThe size of the area around the frame's border defining a region from which image points will not be used for tracking, with range [0, min(width, height) / 4)
Returns
True, if a valid homography could be determined

◆ trackPoints() [2/2]

static bool Ocean::Tracking::HomographyTracker::trackPoints ( const Frame yPreviousFrame,
const CV::FramePyramid previousFramePyramid,
const CV::FramePyramid currentFramePyramid,
RandomGenerator randomGenerator,
const Vectors2 previousPositions,
SquareMatrix3 homography,
Worker worker = nullptr,
const unsigned int  patchSize = 31u 
)
static

Tracks a group of given image points from the previous frame to the current frame and determines the corresponding homography afterwards.

The resulting homography will transform points defined in the previous frame to points defined in the current frame (pointCurrent = H * pointPrevious).

Parameters
yPreviousFrameThe previous frame as grayscale frame, with same frame dimension and pixel origin as the previous/current frame, must have pixel format FORMAT_Y8, must be valid
previousFramePyramidThe frame pyramid of the previous frame, must be valid
currentFramePyramidThe frame pyramid of the current frame, with same frame type and layer number as 'previousFramePyramid'
randomGeneratorRandom number generator object
previousPositionsImage points (e.g., string feature points) located in the previous image that will be used for the determination of the homography
homographyResulting homography
workerOptional worker object to distribute the computation
patchSizeThe size of the patches used for tracking, possible values can be [5, 7, 15, 31]
Returns
True, if succeeded

◆ transformPoints()

Vectors2 Ocean::Tracking::HomographyTracker::transformPoints ( const Vectors2 points,
const SquareMatrix3 transformation 
)
inlinestatic

Transforms a given set of points to a new set using a given transformation.

This function will calculate result[i] = transformation * points[i].

Parameters
pointsThe points to be transformed
transformationThe transformation to be used, must be valid
Returns
Resulting transformed points

Field Documentation

◆ currentFramePyramid_

CV::FramePyramid Ocean::Tracking::HomographyTracker::currentFramePyramid_
private

Frame pyramid of the current frame.

◆ patchSize_

unsigned int Ocean::Tracking::HomographyTracker::patchSize_ = 31u
private

The size of the image patches used for tracking, possible values can be [5, 7, 15, 31].

◆ previousFramePyramid_

CV::FramePyramid Ocean::Tracking::HomographyTracker::previousFramePyramid_
private

Frame pyramid of the previous frame.


The documentation for this class was generated from the following file: