Function:OpticalFlowHS

From CUVI Wiki
Revision as of 15:28, 26 April 2012 by Jawad (talk | contribs)

Function

CuviStatus opticalFlowHS(CuviImage* previousImage,
                         CuviImage* nextImage,
                         Cuvi32f* velocityX,
                         Cuvi32f* velocityY,
                         Cuvi32s usePrevious = 0,
                         Cuvi32f lambda = 1.0f ,
                         Cuvi32s iterations = 1,
                         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
velocityX Cuvi32f* Horizontal velocity vector
velocityY Cuvi32f* Vertical velocity vector
usePrevious Cuvi32s use previous (input) velocity field
lambda Cuvi32f Lagrangian multiplier
iterations Cuvi32s Maximum number of iterations
stream CuviStream* GPU stream ID for execution


Image Type Support

Input Output
8uC1 32fC1


Sample

Error creating thumbnail: Unable to save thumbnail to destination



Example

//Image size
CuviSize size = cuviSize(img1->width,img1->height);

//Create two 8-bit Grays-scale CuviImage
CuviImage* gimg1 = new CuviImage(size,img1->depth,img1->nChannels);
CuviImage* gimg2 = new CuviImage(size,img1->depth,img1->nChannels);

//Populate the GPU Images
gimg1->upload(img1->imageData,img1->widthStep);
gimg2->upload(img2->imageData,img2->widthStep);

//Create output memory
Cuvi32f *u, *v;
u=(Cuvi32f*)malloc(img0->width*img0->height*sizeof(Cuvi32f));
v=(Cuvi32f*)malloc(img0->width*img0->height*sizeof(Cuvi32f));

//Calculates flow of each image pixel in two frames using Horn–Schunck method
cuvi::ComputerVision::opticalFlowHS(gimg1,gimg2,u,v);