Foundation (CVFoundation.dll) 14.0
Optical Flow

Functions

cvbres_t OptFlowCreateColorfulOrientationPlot (IMG ImgV, float MaxVectorLength, cvbval_t ScaleSize, IMG &COPImage)
 Creates colorful orientation plot. More...
 
cvbres_t OptFlowLKCalculate (OPTFLOWLK OpticalFlowHandle, IMG Img1, cvbdim_t Img1Index, IMG Img2, cvbdim_t Img2Index, PIXELLIST &result)
 Calculates optical flow for an image pair. More...
 
cvbres_t OptFlowLKCalculateSeq (OPTFLOWLK OpticalFlowHandle, IMG Img, cvbdim_t ImgIndex, PIXELLIST &result)
 Calculates optical flow. More...
 
OPTFLOWLK OptFlowLKCreate (cvbdim_t Width, cvbdim_t Height)
 Creates a handle for calculating the optical flow based on the pyramidal Lucas-Kanade algorithm. More...
 
cvbres_t OptFlowLKGetDistanceThreshold (OPTFLOWLK OpticalFlowHandle, float &Threshold)
 Gets the distance threshold for maximal movement vector length. More...
 
cvbres_t OptFlowLKGetFeatureThreshold (OPTFLOWLK OpticalFlowHandle, float &Threshold)
 Gets minimal Eigen value for a point being considered as a feature. More...
 
cvbres_t OptFlowLKGetNumGaussPyramidLevels (OPTFLOWLK OpticalFlowHandle, cvbval_t &PyrLevels)
 Gets the number of levels for the Gaussian pyramid. More...
 
cvbres_t OptFlowLKGetNumIterationsPerPyramidLevel (OPTFLOWLK OpticalFlowHandle, cvbval_t &IterationsPerLevel)
 Gets the maximal number of iterations to be calculated on every level of the Gaussian-pyramid. More...
 
cvbres_t OptFlowLKGetWindowSize (OPTFLOWLK OpticalFlowHandle, cvbdim_t &WindowSize)
 Gets the search window size for tracking moved feature points. More...
 
cvbres_t OptFlowLKRecalculateFeaturePoints (OPTFLOWLK OpticalFlowHandle)
 Recalculates the feature points that are used for the optical flow calculation. More...
 
cvbres_t OptFlowLKSetDistanceThreshold (OPTFLOWLK OpticalFlowHandle, float Threshold)
 Sets the distance threshold for the optical flow calculation. More...
 
cvbres_t OptFlowLKSetFeatureSeparation (OPTFLOWLK OpticalFlowHandle, cvbval_t Separation)
 Sets the feature separation in pixels. More...
 
cvbres_t OptFlowLKSetFeatureThreshold (OPTFLOWLK OpticalFlowHandle, float Threshold)
 Sets minimal Eigen value for a point being considered as a feature. More...
 
cvbres_t OptFlowLKSetNumGaussPyramidLevels (OPTFLOWLK OpticalFlowHandle, cvbval_t PyrLevels)
 Sets the number Gaussian-pyramid levels to use. More...
 
cvbres_t OptFlowLKSetNumIterationsPerPyramidLevel (OPTFLOWLK OpticalFlowHandle, cvbval_t IterationsPerLevel)
 Sets the maximal number of iterations to be calculated on every level of the Gaussian-pyramid. More...
 
cvbres_t OptFlowLKSetWindowSize (OPTFLOWLK OpticalFlowHandle, cvbdim_t WindowSize)
 Sets the search window size for tracking moved feature points. More...
 

Detailed Description

Function Documentation

◆ OptFlowCreateColorfulOrientationPlot()

cvbres_t OptFlowCreateColorfulOrientationPlot ( IMG  ImgV,
float  MaxVectorLength,
cvbval_t  ScaleSize,
IMG COPImage 
)

Creates colorful orientation plot.

Calculates a colorful orientation plot to display the vector-fields of optical flow calculation. The angle of each vector is set to the hue-channel in HSV-color-model and the magnitude is set to value-channel. Afterwards the result-image is converted to the RGB color model.

Parameters
[in]ImgVThe handle velocity vector image.
[in]MaxVectorLengthMaximal vector length. Crops vector length with this value (> 0).
[in]ScaleSizeThe width of the color scale around the image in pixels. Must be >= 0.
[out]COPImageHandle to receive to the image that contains the colorful orientation plot of the vector field. Remember that this image will need to be released with ReleaseObject() once it is no longer needed.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKCalculate()

cvbres_t OptFlowLKCalculate ( OPTFLOWLK  OpticalFlowHandle,
IMG  Img1,
cvbdim_t  Img1Index,
IMG  Img2,
cvbdim_t  Img2Index,
PIXELLIST result 
)

Calculates optical flow for an image pair.

This function calculates the optical flow between two images Img1 and Img2. It starts a new sequence with Img1, thus new feature points are calculated on Img1.

Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[in]Img1The first image. The image plane must consist of integer or floating point pixels.
[in]Img1IndexPlane index of ImgIn to process.
[in]Img2The second image (e.g., the one following Img1) to which the optical flow is calculated. The same restrictions as for ImgIn apply.
[in]Img2IndexPlane index of ImgRef to process.
[out]resultFour-dimensional PIXELLIST containing first the key-point from Img1 and then the motion vector to the matched key-point in Img2. Release the returned list via ReleaseObject when not needed anymore.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKCalculateSeq()

cvbres_t OptFlowLKCalculateSeq ( OPTFLOWLK  OpticalFlowHandle,
IMG  Img,
cvbdim_t  ImgIndex,
PIXELLIST result 
)

Calculates optical flow.

This function determines the optical flow between the last processed image and a new Img.

No recalculation of the feature points is done, but the old optical flow is used to estimate the new locations.

After each calculation it may happen that some feature points are not found anymore and thus are removed. Use OptFlowLKRecalculateFeaturePoints to do a full recalculation to get a fresh list of feature points.

Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[in]ImgThe current image. The image plane must consist of integer or floating point pixels.
[in]ImgIndexPlane index of ImgIn to process.
[out]resultFour-dimensional PIXELLIST containing first the key-point from the last processed image and then the motion vector to the matched key-point in Img. Release the returned list via ReleaseObject when not needed anymore.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKCreate()

OPTFLOWLK OptFlowLKCreate ( cvbdim_t  Width,
cvbdim_t  Height 
)

Creates a handle for calculating the optical flow based on the pyramidal Lucas-Kanade algorithm.

Creates an optical flow state object that can afterwards be used with the functions of the optical flow module of the Foundation Package (all functions working on the OPTFLOWLK type). Note that the object created by this function must be disposed by calling ReleaseObject from the CVCImg.dll on it.

Attention
After creating the object two new images need to be set until a result is available!
Parameters
[in]WidthWidth of the image to process in pixels.
[in]HeightHeight of the image to process in pixels.
Returns
Returns the reference to the new handle; NULL on error.

◆ OptFlowLKGetDistanceThreshold()

cvbres_t OptFlowLKGetDistanceThreshold ( OPTFLOWLK  OpticalFlowHandle,
float &  Threshold 
)

Gets the distance threshold for maximal movement vector length.

Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[out]ThresholdThreshold for maximal movement vector length per level.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKGetFeatureThreshold()

cvbres_t OptFlowLKGetFeatureThreshold ( OPTFLOWLK  OpticalFlowHandle,
float &  Threshold 
)

Gets minimal Eigen value for a point being considered as a feature.

Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[out]ThresholdMinimal Eigen value for a feature point.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKGetNumGaussPyramidLevels()

cvbres_t OptFlowLKGetNumGaussPyramidLevels ( OPTFLOWLK  OpticalFlowHandle,
cvbval_t &  PyrLevels 
)

Gets the number of levels for the Gaussian pyramid.

For detecting large optical-flow vectors it is necessary to use a larger number of Gaussian pyramid levels. Every additional level doubles the maximum magnitude that can be detected. Without additional levels, only motion vectors up to about 1 to 2 pixels can be detected (depending on the window size used for polynomial expansion).

Parameters
[in]OpticalFlowHandleThe handle of the optical flow state object.
[out]PyrLevelsNumber of scale-levels. 0 means no additional level.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKGetNumIterationsPerPyramidLevel()

cvbres_t OptFlowLKGetNumIterationsPerPyramidLevel ( OPTFLOWLK  OpticalFlowHandle,
cvbval_t &  IterationsPerLevel 
)

Gets the maximal number of iterations to be calculated on every level of the Gaussian-pyramid.

The estimation of optical-flow-vectors can be improved by repeating the calculation fore some iterations.

A higher iteration count may increase processing time during optical flow calculation.

Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[out]IterationsPerLevelMaximal number of iterations per pyramid-level.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKGetWindowSize()

cvbres_t OptFlowLKGetWindowSize ( OPTFLOWLK  OpticalFlowHandle,
cvbdim_t &  WindowSize 
)

Gets the search window size for tracking moved feature points.

Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[out]WindowSizeSearch window size.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKRecalculateFeaturePoints()

cvbres_t OptFlowLKRecalculateFeaturePoints ( OPTFLOWLK  OpticalFlowHandle)

Recalculates the feature points that are used for the optical flow calculation.

New feature points are always calculated at the start of a new sequence (e.g. if OptFlowLKCalculate is called or one of the settings is changed). When OptFlowLKCalculateSeq is called no recalculation of the feature points is done, but the old optical flow is used to estimate the new locations.

After each calculation it may happen that some feature points are not found anymore and thus are removed. Use this function to do a full recalculation to get a fresh list of feature points.

Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h
See also
OptFlowLKSetFeatureThreshold, OptFlowLKSetFeatureSeparation

◆ OptFlowLKSetDistanceThreshold()

cvbres_t OptFlowLKSetDistanceThreshold ( OPTFLOWLK  OpticalFlowHandle,
float  Threshold 
)

Sets the distance threshold for the optical flow calculation.

Attention
When setting new values for these two parameters the optical flow state is reset (two new images need to be set until a result is available)!
Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[in]ThresholdThreshold for maximal distance between old and new feature point per level.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKSetFeatureSeparation()

cvbres_t OptFlowLKSetFeatureSeparation ( OPTFLOWLK  OpticalFlowHandle,
cvbval_t  Separation 
)

Sets the feature separation in pixels.

The feature separation defines the minimal distance between feature points used for the optical flow. Locations with corners normally have a cluster of high Eigen values. To reduce the number of key points and thus to speed up processing use this value.

This setting takes effect only when a new optical flow sequence is started or OptFlowLKRecalculateFeaturePoints is called.

Attention
When setting new values for these two parameters the optical flow state is reset (two new images need to be set until a result is available)!
Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[in]SeparationThe feature separation in pixels; must be larger or equal to 0. Uses the cheaper L1 distance.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKSetFeatureThreshold()

cvbres_t OptFlowLKSetFeatureThreshold ( OPTFLOWLK  OpticalFlowHandle,
float  Threshold 
)

Sets minimal Eigen value for a point being considered as a feature.

High Eigen values indicate corner points in the image where the optical flow can be measured well.

This setting takes effect only when a new optical flow sequence is started or OptFlowLKRecalculateFeaturePoints is called.

Attention
When setting new values for these two parameters the optical flow state is reset (two new images need to be set until a result is available)!
Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[in]ThresholdMinimal Eigen value for a feature point (>= 0).
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKSetNumGaussPyramidLevels()

cvbres_t OptFlowLKSetNumGaussPyramidLevels ( OPTFLOWLK  OpticalFlowHandle,
cvbval_t  PyrLevels 
)

Sets the number Gaussian-pyramid levels to use.

For detecting large optical-flow vectors it is necessary to use a larger number of Gaussian pyramid levels. Every additional level doubles the maximum magnitude that can be detected. Without additional levels, only motion vectors up to about 1 to 2 pixels can be detected (depending on the window size used for polynomial expansion.

Attention
The more pyramid-levels you use, the bigger the influence of the error-prone border region will become, i.e. the smaller the region with reliable results will become.
Additionally, errors may result if the objects that are moving are small and a high number pyramid levels are being used (objects may be averaged out in the process).
When setting new values for this property the optical flow state is reset (two new images need to be set until a result is available)!
Parameters
[in]OpticalFlowHandleThe handle of the optical flow state object.
[in]PyrLevelsNumber of scale-levels. 0 means no additional level. Maximum is limited by the kernel and image size.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKSetNumIterationsPerPyramidLevel()

cvbres_t OptFlowLKSetNumIterationsPerPyramidLevel ( OPTFLOWLK  OpticalFlowHandle,
cvbval_t  IterationsPerLevel 
)

Sets the maximal number of iterations to be calculated on every level of the Gaussian-pyramid.

The estimation of optical-flow-vectors can be improved by repeating the calculation. Typically, one to three iterations are sufficient.

A higher iteration count will increase processing time during optical flow calculation.

Attention
When setting new values for these two parameters the optical flow state is reset (two new images need to be set until a result is available)!
Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[in]IterationsPerLevelNumber of iterations per pyramid-level. Must be >= 1.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h

◆ OptFlowLKSetWindowSize()

cvbres_t OptFlowLKSetWindowSize ( OPTFLOWLK  OpticalFlowHandle,
cvbdim_t  WindowSize 
)

Sets the search window size for tracking moved feature points.

Larger windows increase the processing time and reduce the accuracy, but allow larger motion vectors and may be more stable in noisy images. Use OptFlowLKSetNumIterationsPerPyramidLevel for longer motion vectors and high accuracy.

Attention
When setting new values for this property the optical flow state is reset (two new images need to be set until a result is available)!
Parameters
[in]OpticalFlowHandleHandle of the optical flow state object.
[in]WindowSizeSearch window size.
Returns
A value >= 0 indicates success. All other return values are taken from the definitions in CVCError.h