Computes Dense Optical Flow between each pixel of two images using pyramidal Lucas-Kanade method.
Function
CuviStatus opticalFlowPyrLKDense(CuviImage* previousImage,
CuviImage* nextImage,
Cuvi32f* flowX
Cuvi32f* flowY,
CuviTrackingCriteria criteria,
CuviStream* stream = NULL);
|
Parameters
| Name
|
Type
|
Description
|
| previousImage
|
CuviImage*
|
The first image whose features are to be tracked
|
| nextImage
|
CuviImage*
|
Second image, in which to look for features of first image
|
| flowX
|
Cuvi32f*
|
Horizontal optical flow
|
| flowY
|
Cuvi32f*
|
Vertical optical flow
|
| criteria
|
CuviFeaturesCriteria
|
A structure containing various parameters that affect optical flow calculation
|
| stream
|
CuviStream*
|
GPU stream ID for execution
|
Image Type Support
| Input
|
Output
|
| 2x 8uC1
|
2x Cuvi32f*
|
Samples
First Input Image (8-bit)
|
Second Input Image (8-bit)
|
Optical Flow Magnitude
|
Flow of selected points
|
Example
//Image size
CuviSize size = cuviSize(width,height);
//Create two 8-bit Grays-scale CuviImage objects
CuviImage* gimg1 = new CuviImage(size,8,1);
CuviImage* gimg2 = new CuviImage(size,8,1);
//Populate the GPU Images
gimg1->upload(img1->imageData,img1->widthStep);
gimg2->upload(img2->imageData,img2->widthStep);
Cuvi32f* flowX = new float[width * height];
Cuvi32f* flowY = new float[width * height];
//tracking criteria
CuviTrackingCriteria tc = cuviTrackingCriteria(2,cuviSize(12,12));
//Compute optical flow between first frame and second frame
cuvi::computerVision::opticalFlowPyrLKDense(gimg1,gimg2,flowX,flowY,tc);
|