Ocean
Ocean::CV::Motion< TMetric > Class Template Reference

This class implements patch-based motion techniques. More...

Static Public Member Functions

template<unsigned int tPatchSize>
static bool trackPointsInPyramidMirroredBorder (const Frame &previousFrame, const Frame &currentFrame, const PixelPositions &previousPoints, const PixelPositions &roughPoints, PixelPositions &currentPoints, const unsigned int maximalOffset, const unsigned int coarsestLayerRadiusX, const unsigned int coarsestLayerRadiusY, const FramePyramid::DownsamplingMode downsamplingMode=FramePyramid::DM_FILTER_14641, Worker *worker=nullptr, std::vector< uint32_t > *metricResults=nullptr, std::vector< uint32_t > *metricIdentityResults=nullptr)
 Tracks a set of given points between two frames with pixel accuracy. More...
 
template<unsigned int tPatchSize>
static bool trackPointsInPyramidMirroredBorder (const FramePyramid &previousPyramid, const FramePyramid &currentPyramid, const PixelPositions &previousPoints, const PixelPositions &roughPoints, PixelPositions &currentPoints, const unsigned int coarsestLayerRadiusX, const unsigned int coarsestLayerRadiusY, Worker *worker=nullptr, std::vector< uint32_t > *metricResults=nullptr, std::vector< uint32_t > *metricIdentityResults=nullptr)
 Tracks a set of given points between two frame pyramids, with pixel accuracy. More...
 
template<unsigned int tChannels, unsigned int tPatchSize>
static PixelPosition pointMotionInFrameMirroredBorder (const uint8_t *const frame0, const uint8_t *const frame1, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const PixelPosition &position0, const unsigned int radiusX, const unsigned int radiusY, const unsigned int frame0PaddingElements, const unsigned int frame1PaddingElements, const PixelPosition &rough1=PixelPosition(), uint32_t *const metricResult=nullptr, uint32_t *const metricIdentityResult=nullptr)
 Determines the motion for one given point between two frames by application of an image patch. More...
 
template<unsigned int tPatchSize>
static PixelPosition pointMotionInFrameMirroredBorder (const uint8_t *const frame0, const uint8_t *const frame1, const unsigned int channels, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const PixelPosition &position0, const unsigned int radiusX, const unsigned int radiusY, const unsigned int frame0PaddingElements, const unsigned int frame1PaddingElements, const PixelPosition &rough1=PixelPosition(), uint32_t *const metricResult=nullptr, uint32_t *const metricIdentityResult=nullptr)
 Determines the motion for one given point between two frames by application of an image patch. More...
 

Static Protected Member Functions

template<unsigned int tPatchSize>
static void trackPointsInPyramidMirroredBorderSubset (const FramePyramid *previousPyramid, const FramePyramid *currentPyramid, const unsigned int numberLayers, const PixelPositions *previousPoints, const PixelPositions *roughPoints, PixelPositions *currentPoints, const unsigned int coarsestLayerRadiusX, const unsigned int coarsestLayerRadiusY, uint32_t *metricResults, uint32_t *metricIdentityResults, const unsigned int firstPoint, const unsigned int numberPoints)
 Tracks a subset of given points between two frame pyramids. More...
 

Detailed Description

template<typename TMetric = SumSquareDifferences>
class Ocean::CV::Motion< TMetric >

This class implements patch-based motion techniques.

Template Parameters
TMetricThe metric that is applied for measurements with pixel accuracy
See also
MotionSAD, MotionSSD, MotionZeroMeanSSD.

Member Function Documentation

◆ pointMotionInFrameMirroredBorder() [1/2]

template<typename TMetric >
template<unsigned int tPatchSize>
PixelPosition Ocean::CV::Motion< TMetric >::pointMotionInFrameMirroredBorder ( const uint8_t *const  frame0,
const uint8_t *const  frame1,
const unsigned int  channels,
const unsigned int  width0,
const unsigned int  height0,
const unsigned int  width1,
const unsigned int  height1,
const PixelPosition position0,
const unsigned int  radiusX,
const unsigned int  radiusY,
const unsigned int  frame0PaddingElements,
const unsigned int  frame1PaddingElements,
const PixelPosition rough1 = PixelPosition(),
uint32_t *const  metricResult = nullptr,
uint32_t *const  metricIdentityResult = nullptr 
)
inlinestatic

Determines the motion for one given point between two frames by application of an image patch.

Patch pixels outside the frame are mirrored into the frame before comparison.

Parameters
frame0The first frame, must be valid
frame1The second frame, must be valid
channelsThe number of frame channels, with range [1, 4]
width0Width of the first frame in pixel, with range [tPatchSize/2, infinity)
height0Height of the first frame in pixel, with range [tPatchSize/2, infinity)
width1Width of the second frame in pixel, with range [tPatchSize/2, infinity)
height1Height of the second frame in pixel, with range [tPatchSize/2, infinity)
position0The position in the first frame, with range [0, width - 1]x[0, height - 1]
radiusXThe search radius in horizontal direction, in pixel, with range [0, width - 1]
radiusYThe search radius in vertical direction, in pixel, with range [0, height - 1]
frame0PaddingElementsThe number of padding elements at the end of each row of the first frame, in elements, with range [0, infinity)
frame1PaddingElementsThe number of padding elements at the end of each row of the second frame, in elements, with range [0, infinity)
rough1The optional rough guess of the point in the second frame, an invalid position if unknown
metricResultOptional resulting matching quality of the applied metric, nullptr if the result does not matter
metricIdentityResultOptional resulting matching quality of the applied metric between both frames at the identity location (the previous and rough position), nullptr if the result does not matter
Returns
Best matching position in the second frame
Template Parameters
tPatchSizeThe size of the square patch (the edge length) in pixel, with range [3, infinity), must be odd, recommended is 5, 7, 15, 31, or 63

◆ pointMotionInFrameMirroredBorder() [2/2]

template<typename TMetric >
template<unsigned int tChannels, unsigned int tPatchSize>
PixelPosition Ocean::CV::Motion< TMetric >::pointMotionInFrameMirroredBorder ( const uint8_t *const  frame0,
const uint8_t *const  frame1,
const unsigned int  width0,
const unsigned int  height0,
const unsigned int  width1,
const unsigned int  height1,
const PixelPosition position0,
const unsigned int  radiusX,
const unsigned int  radiusY,
const unsigned int  frame0PaddingElements,
const unsigned int  frame1PaddingElements,
const PixelPosition rough1 = PixelPosition(),
uint32_t *const  metricResult = nullptr,
uint32_t *const  metricIdentityResult = nullptr 
)
static

Determines the motion for one given point between two frames by application of an image patch.

Patch pixels outside the frame are mirrored into the frame before comparison.

Parameters
frame0The first frame, must be valid
frame1The second frame, must be valid
width0Width of the first frame in pixel, with range [tPatchSize/2, infinity)
height0Height of the first frame in pixel, with range [tPatchSize/2, infinity)
width1Width of the second frame in pixel, with range [tPatchSize/2, infinity)
height1Height of the second frame in pixel, with range [tPatchSize/2, infinity)
position0The position in the first frame, with range [0, width - 1]x[0, height - 1]
radiusXThe search radius in horizontal direction, in pixel, with range [0, width - 1]
radiusYThe search radius in vertical direction, in pixel, with range [0, height - 1]
frame0PaddingElementsThe number of padding elements at the end of each row of the first frame, in elements, with range [0, infinity)
frame1PaddingElementsThe number of padding elements at the end of each row of the second frame, in elements, with range [0, infinity)
rough1The optional rough guess of the point in the second frame, an invalid position if unknown
metricResultOptional resulting matching quality of the applied metric, nullptr if the result does not matter
metricIdentityResultOptional resulting matching quality of the applied metric between both frames at the identity location (the previous and rough position), nullptr if the result does not matter
Returns
Best matching position in the second frame
Template Parameters
tChannelsThe number of frame channels, with range [1u, infinity)
tPatchSizeThe size of the square patch (the edge length) in pixel, with range [3, infinity), must be odd, recommended is 5, 7, 15, 31, or 63

◆ trackPointsInPyramidMirroredBorder() [1/2]

template<typename TMetric >
template<unsigned int tPatchSize>
bool Ocean::CV::Motion< TMetric >::trackPointsInPyramidMirroredBorder ( const Frame previousFrame,
const Frame currentFrame,
const PixelPositions previousPoints,
const PixelPositions roughPoints,
PixelPositions currentPoints,
const unsigned int  maximalOffset,
const unsigned int  coarsestLayerRadiusX,
const unsigned int  coarsestLayerRadiusY,
const FramePyramid::DownsamplingMode  downsamplingMode = FramePyramid::DM_FILTER_14641,
Worker worker = nullptr,
std::vector< uint32_t > *  metricResults = nullptr,
std::vector< uint32_t > *  metricIdentityResults = nullptr 
)
static

Tracks a set of given points between two frames with pixel accuracy.

Actually, this function simply creates two frame pyramids and invokes the corresponding function needing frame pyramid as parameters.
The motion is determined by application of an image patch centered around the point to be tracked.
The points are tracked unidirectional (from the previous frame to the current frame).
If a point is near the frame border, a mirrored image patch is applied

Parameters
previousFrameThe previous frame in which the previous points are located, must be valid
currentFrameThe current frame, with same pixel format and pixel orientation as the previous frame, must be valid
previousPointsThe points that are located in the previous frame (the points to be tracked from the previous frame to the current frame), with ranges [0, previousFrame.width())x[0, previousFrame.height())
roughPointsRough locations of the previous points in the current frame (if known), otherwise simply provide the previous points again, one for each previous point, with ranges [0, currentFrame.width())x[0, currentFrame.height())
currentPointsResulting current points, that have been tracked from the previous frame to the current frame, with ranges [0, currentFrame.width())x[0, currentFrame.height())
maximalOffsetMaximal expected offset between two corresponding points in pixel, defined in the domain of previous/current frame, with range [1, infinity)
coarsestLayerRadiusXThe search radius on the coarsest pyramid layer in horizontal direction, in pixel, with range [0, infinity)
coarsestLayerRadiusYThe search radius on the coarsest pyramid layer in vertical direction, in pixel, with range [0, infinity)
downsamplingModeThe down sampling mode that is applied to create the pyramid layers
workerOptional worker object to distribute the computation
metricResultsOptional resulting matching quality of the applied metric, nullptr if the results do not matter
metricIdentityResultsOptional resulting matching quality of the applied metric between both frames at the identity location (the previous and rough position), nullptr if the results do not matter
Returns
True, if succeeded
Template Parameters
tPatchSizeThe size of the square patch (the edge length) in pixel, with range [3, infinity), must be odd, recommended is 5, 7, 15, 31, or 63

◆ trackPointsInPyramidMirroredBorder() [2/2]

template<typename TMetric >
template<unsigned int tPatchSize>
bool Ocean::CV::Motion< TMetric >::trackPointsInPyramidMirroredBorder ( const FramePyramid previousPyramid,
const FramePyramid currentPyramid,
const PixelPositions previousPoints,
const PixelPositions roughPoints,
PixelPositions currentPoints,
const unsigned int  coarsestLayerRadiusX,
const unsigned int  coarsestLayerRadiusY,
Worker worker = nullptr,
std::vector< uint32_t > *  metricResults = nullptr,
std::vector< uint32_t > *  metricIdentityResults = nullptr 
)
static

Tracks a set of given points between two frame pyramids, with pixel accuracy.

The points are tracked unidirectional (from the previous frame to the current frame).
The motion is determined by application of an image patch centered around the point to be tracked.
If a point is near the frame border, a mirrored image patch is applied.

Parameters
previousPyramidThe frame pyramid of the previous frame in which the previous points are located, must be valid
currentPyramidThe frame pyramid of the current frame, with same pixel format and pixel origin as the previous frame pyramid, must be valid
previousPointsThe points that are located in the previous frame (the points to be tracked from the previous frame to the current frame), with ranges [0, previousPyramid.finestWidth())x[0, previousPyramid.finestHeight())
roughPointsRough locations of the previous points in the current frame (if known), otherwise simply provide the previous points again, one for each previous point, with ranges [0, currentPyramid.finestWidth())x[0, currentPyramid.finestHeight())
currentPointsResulting current points, that have been tracked from the previous frame to the current frame, with ranges [0, currentPyramid.finestWidth())x[0, currentPyramid.finestHeight())
coarsestLayerRadiusXThe search radius on the coarsest pyramid layer in horizontal direction, in pixel, with range [0, infinity)
coarsestLayerRadiusYThe search radius on the coarsest pyramid layer in vertical direction, in pixel, with range [0, infinity)
workerOptional worker object to distribute the computation
metricResultsOptional resulting matching quality of the applied metric, nullptr if the results do not matter
metricIdentityResultsOptional resulting matching quality of the applied metric between both frames at the identity location (the previous and rough position), nullptr if the results do not matter
Returns
True, if succeeded
Template Parameters
tPatchSizeThe size of the square patch (the edge length) in pixel, with range [3, infinity), must be odd, recommended is 5, 7, 15, 31, or 63

◆ trackPointsInPyramidMirroredBorderSubset()

template<typename TMetric >
template<unsigned int tPatchSize>
void Ocean::CV::Motion< TMetric >::trackPointsInPyramidMirroredBorderSubset ( const FramePyramid previousPyramid,
const FramePyramid currentPyramid,
const unsigned int  numberLayers,
const PixelPositions previousPoints,
const PixelPositions roughPoints,
PixelPositions currentPoints,
const unsigned int  coarsestLayerRadiusX,
const unsigned int  coarsestLayerRadiusY,
uint32_t *  metricResults,
uint32_t *  metricIdentityResults,
const unsigned int  firstPoint,
const unsigned int  numberPoints 
)
staticprotected

Tracks a subset of given points between two frame pyramids.

The points are tracked unidirectional (from the previous frame to the current frame).
If a point is near the frame border, a mirrored image patch is applied.

Parameters
previousPyramidPrevious frame pyramid
currentPyramidCurrent frame pyramid, with same frame type as the previous frame
numberLayersThe number of pyramid layers that will be used for tracking, with range [1, min(pyramids->layers(), coarsest layer that match with the patch size)]
previousPointsA set of points that are located in the previous frame
roughPointsThe rough points in the current frame (if known), otherwise the prevousPoints may be provided
currentPointsResulting current points, that have been tracking between the two points
coarsestLayerRadiusXThe search radius on the coarsest pyramid layer in horizontal direction, in pixel, with range [0, infinity)
coarsestLayerRadiusYThe search radius on the coarsest pyramid layer in vertical direction, in pixel, with range [0, infinity)
metricResultsOptional resulting results of the applied metric, nullptr if the results do not matter
metricIdentityResultsOptional resulting results of the applied metric in both frames at the same previous position, nullptr if the results do not matter
firstPointThe first point to be handled, with range [0, numberPoints - 1]
numberPointsThe number of points to handled, with range [1, infinity)
Template Parameters
tPatchSizeThe size of the square patch (the edge length) in pixel, with range [3, infinity), must be odd, recommended is 5, 7, 15, 31, or 63

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