Difference between revisions of "Function:OpticalFlowPyrLKDense"

From CUVI Wiki
Line 62: Line 62:
|}
|}


===Samples===
====Samples====
{|
[[File:OF_frame1.png|none|frame|First Input Image (8-bit)]]
|-
<br/>
|[[File:OF_frame1.png|frame|First Input Image (8-bit)]]
[[File:OF_frame2.png|none|frame|Second Input Image (8-bit)]]
|[[File:OF_frame2.png|frame|Second Input Image (8-bit)]]
<br/>
|-
[[File:OF_flowMag.png|none|frame| Optical Flow Magnitude]]
|[[File:OF_flowMag.png|frame| Optical Flow Magnitude]]
<br/>
|[[File:OF_sparseFlow.png|frame| Flow of selected points]]
[[File:OF_sparseFlow.png|none|frame| Flow of selected points]]
|}
<br/>
 
 


===Example===
===Example===

Revision as of 22:17, 18 October 2022

Computes Dense Optical Flow between each pixel of two images using pyramidal Lucas-Kanade method.

Function

CuviStatus opticalFlowPyrLKDense(const CuviImage& previous,
                                 const CuviImage& next,
                                 Cuvi32f* flowX
                                 Cuvi32f* flowY,
                                 const CuviTrackingCriteria criteria,
                                 const CuviStream& stream = CuviStream());

Parameters

Name Type Description
previous CuviImage& The first image whose features are to be tracked
next CuviImage& Second image, in which to look for features of first image
flowX Cuvi32f* Horizontal optical flow
flowY Cuvi32f* Vertical optical flow
criteria const CuviFeaturesCriteria A structure containing various parameters that affect optical flow calculation
stream const CuviStream& GPU stream ID for execution

Image Type Support

Input Output
2x 8uC1 2x Cuvi32f*

Samples

Error creating thumbnail: Unable to save thumbnail to destination
First Input Image (8-bit)


Error creating thumbnail: Unable to save thumbnail to destination
Second Input Image (8-bit)


Error creating thumbnail: Unable to save thumbnail to destination
Optical Flow Magnitude


Error creating thumbnail: Unable to save thumbnail to destination
Flow of selected points


Example

//Create two 8-bit Grays-scale CuviImage objects
CuviImage gimg1 = cuvi::io::loadImage(path,CUVI_LOAD_IMAGE_GRAYSCALE);
CuviImage gimg2 = cuvi::io::loadImage(path,CUVI_LOAD_IMAGE_GRAYSCALE);


Cuvi32f* flowX = new Cuvi32f[gimg1.width() * gimg1.height()];
Cuvi32f* flowY = new Cuvi32f[gimg1.width() * gimg1.height()];

//tracking criteria
CuviTrackingCriteria tc;

//Compute optical flow between first frame and second frame
cuvi::computerVision::opticalFlowPyrLKDense(gimg1,gimg2,flowX,flowY,tc);