views:

273

answers:

1

Problem: I'm trying to align two frames of a moving video.

I'm currently trying to use the function "cvCalcOpticalFlowLK" and the result outputs velocity vectors of x and y in the form of a "CvArr".

So I obtained the result, but i'm not sure how to use these vector arrays.

My question is this... how do i know what is the velocity of each pixel? Is it just the value of each pixel value at that particular point?

Note: I would've used the other optical flow functions such as cvCalcOpticalFlowPyrLK() as it is much easier, but i want the dense optical flow.

A: 

Apparently my original assumption was true. The "velx" and "vely" outputs from the optical flow function are the actual velocities for each pixel value. To best extract them, I accessed the pixel from the raw data and pulled the value. There are 2 ways to do this.

cvGet2D() -- this way is slower but if you only need to access 1 pixel it's okay.

or

(uchar*)(image->imageData + height*image->widthStep + width);

(image is an IplImage, width and height are just the corresponding widths and heights of the image)

monky822