Foundation (OpticalFlow.dll) 14.0
Initialization Functions

Functions

OPTICALFLOW OptFlowCreate (cvbdim_t width, cvbdim_t height, cvbval_t blockSize, cvbval_t latticeSpacing, double qualityThreshold, cvbval_t rangeExtension, cvbval_t interFrameFilter)
 Generate an OpticalFlow object for storing temporary calculation data. More...
 
cvbbool_t OptFlowCreateCompatibleImg (cvbdim_t width, cvbdim_t height, IMG &image)
 Creates an image that is compatible with the requirements of the OptFlowColorOverlay function for creating a visualization of the motion vector field. More...
 
cvbbool_t OptFlowDestroy (OPTICALFLOW opticalFlow)
 Releases the CVB Optical Flow handle. More...
 

Detailed Description

Function Documentation

◆ OptFlowCreate()

OPTICALFLOW OptFlowCreate ( cvbdim_t  width,
cvbdim_t  height,
cvbval_t  blockSize,
cvbval_t  latticeSpacing,
double  qualityThreshold,
cvbval_t  rangeExtension,
cvbval_t  interFrameFilter 
)

Generate an OpticalFlow object for storing temporary calculation data.

Almost all functions in CVB OpticalFlow need a handle to an object that holds temporary and result data from the optical flow calculation. Therefore, this initialization function needs to be invoked prior to calling any other CVB Optical Flow function in order to obtain a valid handle to such an object.

Attention
After processing is finished, the handle needs to be released by means of the ReleaseObject function from the CVCImg.dll.
Parameters
[in]widthWidth of the images to be processed.
Attention: Accepts only values >= 32.
[in]heightHeight of the images to be processed.
Attention: Accepts only values >= 32.
[in]blockSizeBlock size determines the size of the square correlation blocks used for calculating the motion vectors. The block size is given in pixels and it is directly linked to the range of the detectable motion components and to the spatial resolution. Larger block sizes increase the range of detectable motions but decrease the spatial resolution of the flow field. The minimum acceptable block size is 16 pixels.

Maximum detection range without range extension (see below): ± 1/2 * blocksize
Acceptable values: 8 <= blocksize <= min(width, height).
[in]latticeSpacingSpacing between the image points at which the optical flow is being calculated. This value determines the spatial resolution of the resulting flow field. A value of 1 means that the motion vector is determined for each pixel of the input image, while e.g., using a value of 2, every second pixel is skipped.
Higher values increase the the calculation speed but reduce the spatial resolution.

Hint: Even though it is possible to use a value of 1 in order to obtain a dense field for the optical flow, in most cases it is sufficient to work with larger values like 6 or higher. This greatly decreases the computation time. In most cases the reduced lateral resolution will still contain sufficient information about the local motions in the image.

Acceptable values: latticeSpacing >= 1.
[in]qualityThresholdThreshold for the degree of structural correlation between the blocks of the two consecutive images. If the resulting correlation value is less than qualityThreshold, the components of the motion vector for this location will be set to zero.

Acceptable values: 0.0 <= qualityThreshold <= 1.0.
[in]rangeExtensionExtends the range of the detectable motion components by performing and utilising an internal pre-calculation of the flow field on images with a reduced resolution.
Maximum detection range using range extension: ± 1/2 * blockSize * rangeExtension.

Acceptable values: 1 <= rangeExtension <= min(width, height) / blockSize.
[in]interFrameFilterThe inter frame filter parameter specifies the number of frames over which to smooth results. Result smoothing can be helpful in that it reduces the influence on local glitches on the results as temporal smoothing averages out these effect. However, like with all sliding average filters, using higher inter frame filter values will lead to a delayed response of the calculated motion vectors to local motion.

Acceptable values: >= 1
Returns
If all input values were acceptable, a valid CVB Optical Flow handle will be returned. Otherwise the return value will be nullptr. In this case, call OptFlowGetErrorMessage to retrieve additional information.
Related Topics:
Calculating the optical flow, OPTICALFLOW, OptFlowCalculate, OptFlowCalculateSeq, OptFlowDestroy, OptFlowGetErrorMessage

◆ OptFlowCreateCompatibleImg()

cvbbool_t OptFlowCreateCompatibleImg ( cvbdim_t  width,
cvbdim_t  height,
IMG &  image 
)

Creates an image that is compatible with the requirements of the OptFlowColorOverlay function for creating a visualization of the motion vector field.

This function effectively creates an image with ARGB pixels (8 bits per component) that are stored in a contiguous array so that the OptFlowColorOverlay function can use this image to paint motion arrows into it.

It is - strictly speaking - not a requirement for the input image to OptFlowColorOverlay to be generated by an OptFlowCreateCompatibleImg call. OptFlowColorOverlay will work with any CVB image that has matching properties (width, height, data type) and memory layout.

Parameters
[in]widthWidth of the image to be created.
Acceptable values: width >= 4
[in]heightHeight of the image to be created.
Acceptable values: width >= 4
[out]imageHandle that receives the newly create CVB. Remember to release this image with the ReleaseObject function from the CVCImg.dll once it is no longer needed.
Returns
TRUE on success, FALSE on failure (in this case an error message can be retrieved with OptFlowGetErrorMessage).
Related Topics:
OptFlowColorOverlay

◆ OptFlowDestroy()

cvbbool_t OptFlowDestroy ( OPTICALFLOW  opticalFlow)

Releases the CVB Optical Flow handle.

Call this function on handles created with OptFlowCreate in order to release the resources that have been allocated for these objects.

Parameters
[in]opticalFlowCVB Optical Flow handle to be released.
Returns
TRUE if the handle was successfully release, FALSE otherwise. Note that starting with CVB 13.01.000 the implementation of OptFlowDestroy will actually call ReleaseObject from the CVCImg.dll and simply return the value returned by ReleaseObject.
Related Topics:
OPTICALFLOW, OptFlowCreate,