Foundation (OpticalFlow.dll) 14.0
Calculation Functions

Functions

cvbbool_t OptFlowCalculate (OPTICALFLOW opticalFlow, IMG cvbImage1, IMG cvbImage2, cvbval_t noiseValue, double minVector, double maxVector, TOptFlowInterpolation interpolation)
 Determines the optical flow between the current image and a reference image. More...
 
cvbbool_t OptFlowCalculateSeq (OPTICALFLOW opticalFlow, IMG cvbImage, cvbval_t noiseValue, double minVector, double maxVector, TOptFlowInterpolation interpolation)
 Determines the optical flow between the current image and a reference image with the same methods that OptFlowCalculate uses. More...
 
cvbbool_t OptFlowGetVcPtr (const OPTICALFLOW opticalFlow, float *&pVcBase)
 Retrieves a pointer to a contiguous float array with values for the degree of structural correlation c for the block-matching result of each pixel. More...
 
cvbbool_t OptFlowGetVxPtr (OPTICALFLOW opticalFlow, float *&pVxBase)
 This function will retrieve a pointer to a contiguous float array which contains the results for the x-components of the motion vectors V. More...
 
cvbbool_t OptFlowGetVyPtr (const OPTICALFLOW opticalFlow, float *&pVyBase)
 This function will retrieve a pointer to a contiguous float array which contains the results for the y-components of the motion vectors V. More...
 

Detailed Description

Function Documentation

◆ OptFlowCalculate()

cvbbool_t OptFlowCalculate ( OPTICALFLOW  opticalFlow,
IMG  cvbImage1,
IMG  cvbImage2,
cvbval_t  noiseValue,
double  minVector,
double  maxVector,
TOptFlowInterpolation  interpolation 
)

Determines the optical flow between the current image and a reference image.

The specific parameters for the calculation, such as the block size, lattice spacing etc., have to be defined during the initializing call of OptFlowCreate.

The results of the optical flow calculation will be stored in three separate float-arrays. The base addresses of these arrays may be queried by means of OptFlowGetVxPtr, OptFlowGetVyPtr, and OptFlowGetVcPtr.

CVB image objects of the following data types can be processed by OptFlowCalculate and OptFlowCalculateSeq:

Monochrome:

  • Integer
    • 8 bit signed or unsigned
    • 16 bit signed or unsigned
    • 32 bit signed or unsigned
  • Float
    • 32 bit
    • 64 bit Color:
  • Integer
    • RGB 8 bits per plane
    • RGB 16 bits per plane
    • YCbCr 8 bits per plane
    • YCbCr 16 bits per plane
    • YUV 8 bits per plane
    • YUV 16 bits per plane
Parameters
[in]opticalFlowCVB Optical Flow handle as returned by OptFlowCreate.
[in]cvbImage1cvbImage Handle to the CVB image object holding the current pixel data on which to calculate the motion vectors. The dimensions of this image have to be the same as specified in the OptFlowCreate call that generated the handle passed as opticalFlow
[in]cvbImage2Handle to the CVB image object holding the reference pixel data on which to calculate the motion vectors. The dimensions of this image have to be the same as specified in the OptFlowCreate call that generated the handle passed as opticalFlow
[in]noiseValueThreshold for the sensitivity on texture changes. The value specifies the gray value difference, which is considered as noise. For a given lattice point the motion vector will not be calculated if the difference of gray values between two images is below noiseValue for more than 80% of the pixels around this point.
[in]minVectorThreshold that defines the minimum absolute value of a motion vector result. Motion vectors with an absolute value smaller than minVector will be set to zero.
[in]maxVectorThreshold that defines the maximum absolute value of a motion vector result. Motion vectors with an absolute value larger than maxVector will be set to zero.
[in]interpolationDetermines the method for generating interpolated motion vectors at pixels between the lattice points for which the optical flow is actually calculated. Must be one of the enum values from TOptFlowInterpolation. If OFI_None is chosen, no motion vectors will be interpolated for pixels between the actual optical flow lattice. Valid results will then only be found at pixels located on grid-points of the evaluation lattice.
Returns
TRUE if the calculation could be carried out successfully, FALSE otherwise (in this case an error-message can be retrieved with OptFlowGetErrorMessage).
Related Topics:
Calculating the optical flow, OPTICALFLOW, OptFlowCalculateSeq, OptFlowGetVxPtr, OptFlowGetVyPtr, OptFlowGetVcPtr, OptFlowGetErrorMessage

◆ OptFlowCalculateSeq()

cvbbool_t OptFlowCalculateSeq ( OPTICALFLOW  opticalFlow,
IMG  cvbImage,
cvbval_t  noiseValue,
double  minVector,
double  maxVector,
TOptFlowInterpolation  interpolation 
)

Determines the optical flow between the current image and a reference image with the same methods that OptFlowCalculate uses.

The difference between OptFlowCalculateSeq and OptFlowCalculateSeq is that for OptFlowCalculateSeq only the current image is submitted, while the reference image is taken from an internal copy of the "current image" resulting from a previous call to OptFlowCalculate or OptFlowCalculateSeq. Therefore, this function has a slightly higher performance than OptFlowCalculate and it is recommended to use OptFlowCalculateSeq for image sequences.

The specific parameters for the calculation, such as the block size, lattice spacing etc., have to be defined during the initializing call of OptFlowCreate.

The results of the optical flow calculation will be stored in three separate float-arrays. The base addresses of these arrays may be queried by means of OptFlowGetVxPtr, OptFlowGetVyPtr, and OptFlowGetVcPtr.

CVB image objects of the following data types can be processed by OptFlowCalculate and OptFlowCalculateSeq:

Monochrome:

  • Integer
    • 8 bit signed or unsigned
    • 16 bit signed or unsigned
    • 32 bit signed or unsigned
  • Float
    • 32 bit
    • 64 bit Color:
  • Integer
    • RGB 8 bits per plane
    • RGB 16 bits per plane
    • YCbCr 8 bits per plane
    • YCbCr 16 bits per plane
    • YUV 8 bits per plane
    • YUV 16 bits per plane
Parameters
[in]opticalFlowCVB Optical Flow handle as returned by OptFlowCreate.
[in]cvbImageHandle to the CVB image object holding the current pixel data on which to calculate the motion vectors. The dimensions of this image have to be the same as specified in the OptFlowCreate call that generated the handle passed as opticalFlow
  • YUB 16 bits per plane
[in]noiseValueThreshold for the sensitivity on texture changes. The value specifies the gray value difference, which is considered as noise. For a given lattice point the motion vector will not be calculated if the difference of gray values between two images is below noiseValue for more than 80% of the pixels around this point.
[in]minVectorThreshold that defines the minimum absolute value of a motion vector result. Motion vectors with an absolute value smaller than minVector will be set to zero.
[in]maxVectorThreshold that defines the maximum absolute value of a motion vector result. Motion vectors with an absolute value larger than maxVector will be set to zero.
[in]interpolationDetermines the method for generating interpolated motion vectors at pixels between the lattice points for which the optical flow is actually calculated. Must be one of the enum values from TOptFlowInterpolation. If OFI_None is chosen, no motion vectors will be interpolated for pixels between the actual optical flow lattice. Valid results will then only be found at pixels located on grid-points of the evaluation lattice.
Returns
TRUE if the calculation could be carried out successfully, FALSE otherwise (in this case an error-message can be retrieved with OptFlowGetErrorMessage).
Related Topics:
Calculating the optical flow, OPTICALFLOW, OptFlowCalculate, OptFlowGetVxPtr, OptFlowGetVyPtr, OptFlowGetVcPtr, OptFlowGetErrorMessage

◆ OptFlowGetVcPtr()

cvbbool_t OptFlowGetVcPtr ( const OPTICALFLOW  opticalFlow,
float *&  pVcBase 
)

Retrieves a pointer to a contiguous float array with values for the degree of structural correlation c for the block-matching result of each pixel.

The c values in this array are updated each time OptFlowCalculate or OptFlowCalculateSeq are called.

The array has width * height elements, independent on the settings for latticeSpacing in the OptFlowCreate call that generated the OPTICALFLOW object and the interpolation specified in the OptFlowCalculate or OptFlowCalculateSeq call that last updated the result field. The values for Vc are in the range [0.0...1.0]. A Vc value of 0.0 means that the degree of correlation was less than the parameter qualityThreshold specified in the function OptFlowCreate. In this case, the vector components Vx and Vy are zero for this pixel and they do not represent valid motions. Pixels where Vc is larger than qualityThreshold represent valid results. Larger Vc values indicate better correlation and thus more reliable results.

The pVcBase needs to be queried only once after a valid CVB Optical Flow handle has been retrieved. The pointers remain valid until the OPTICALFLOW object is released.

Parameters
[in]opticalFlowValid CVB Optical Flow handle as created by OptFlowCreate.
[out]pVcBasePointer to a contiguous float array with values for the degree of structural correlation for the block-matching result for each pixel.
Returns
TRUE on success, FALSE on failure (in this case an error message can be retrieved with OptFlowGetErrorMessage).
Related Topics:
Calculating the optical flow, OPTICALFLOW, OptFlowCalculateSeq, OptFlowCalculate, OptFlowGetVxPtr, OptFlowGetVyPtr, OptFlowGetErrorMessage

◆ OptFlowGetVxPtr()

cvbbool_t OptFlowGetVxPtr ( OPTICALFLOW  opticalFlow,
float *&  pVxBase 
)

This function will retrieve a pointer to a contiguous float array which contains the results for the x-components of the motion vectors V.

The Vx values in this array are updated each time OptFlowCalculate or OptFlowCalculateSeq are called.

The array has width * height elements, independent on the settings for latticeSpacing in the OptFlowCreate call that generated the OPTICALFLOW object and the interpolation specified in the OptFlowCalculate or OptFlowCalculateSeq call that last updated the result field. However, depending on these parameters, and on whether a motion vector could be estimated, not all values in this array represent valid results.

To find out whether a Vx value at a certain pixel position
represents a valid result, the corresponding correlation value Vc for this pixel needs to be checked. Only if Vc is larger than zero, the result for Vx is valid. A pointer to a float array with Vc values can be obtained with the OptFlowGetVcPtr function. The pointers to these arrays need to be queried only once after a valid CVB Optical Flow handle has been retrieved. The pointers remain valid until the OPTICALFLOW object is released.

Parameters
[in]opticalFlowValid CVB Optical Flow handle as generated by OptFlowCreate.
[out]pVxBasePointer to a contiguous float array with results for the x-components of the motion vectors for each pixel.
Returns
TRUE on success, FALSE on failure (in this case an error message can be retrieved with OptFlowGetErrorMessage).
Related Topics:
Calculating the optical flow, OPTICALFLOW, OptFlowCalculateSeq, OptFlowCalculate, OptFlowGetVyPtr, OptFlowGetVcPtr, OptFlowGetErrorMessage

◆ OptFlowGetVyPtr()

cvbbool_t OptFlowGetVyPtr ( const OPTICALFLOW  opticalFlow,
float *&  pVyBase 
)

This function will retrieve a pointer to a contiguous float array which contains the results for the y-components of the motion vectors V.

The Vy values in this array are updated each time OptFlowCalculate or OptFlowCalculateSeq are called.

The array has width * height elements, independent on the settings for latticeSpacing in the OptFlowCreate call that generated the OPTICALFLOW object and the interpolation specified in the OptFlowCalculate or OptFlowCalculateSeq call that last updated the result field. However, depending on these parameters, and on whether a motion vector could be estimated, not all values in this array represent valid results.

To find out whether a Vy value at a certain pixel position
represents a valid result, the corresponding correlation value Vc for this pixel needs to be checked. Only if Vc is larger than zero, the result for Vy is valid. A pointer to a float array with Vc values can be obtained with the OptFlowGetVcPtr function. The pointers to these arrays need to be queried only once after a valid CVB Optical Flow handle has been retrieved. The pointers remain valid until the OPTICALFLOW object is released.

Parameters
[in]opticalFlowValid CVB Optical Flow handle as generated by OptFlowCreate.
[out]pVyBasePointer to a contiguous float array with results for the x-components of the motion vectors for each pixel.
Returns
TRUE on success, FALSE on failure (in this case an error message can be retrieved with OptFlowGetErrorMessage).
Related Topics:
Calculating the optical flow, OPTICALFLOW, OptFlowCalculateSeq, OptFlowCalculate, OptFlowGetVxPtr, OptFlowGetVcPtr, OptFlowGetErrorMessage