Ask Your Question
0

Output of calcOpticalFlowFarneback

asked 2013-10-30 00:48:49 -0600

Ioanna gravatar image

Hello, I am using this function calcOpticalFlowFarneback

public static void calcOpticalFlowFarneback(Mat prev, Mat next, Mat flow, double pyr_scale, int levels, int winsize, int iterations, int poly_n, double poly_sigma, int flags) Computes a dense optical flow using the Gunnar Farneback's algorithm.

The function finds an optical flow for each prev pixel using the [Farneback2003] algorithm so that

prev(y,x) ~ next(y + flow(y,x)[1], x + flow(y,x)[0])

Parameters: prev - first 8-bit single-channel input image. next - second input image of the same size and the same type as prev. flow - computed flow image that has the same size as prev and type CV_32FC2. pyr_scale - parameter, specifying the image scale (<1) to build pyramids for each image; pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous one. levels - number of pyramid layers including the initial image; levels=1 means that no extra layers are created and only the original images are used. winsize - averaging window size; larger values increase the algorithm robustness to image noise and give more chances for fast motion detection, but yield more blurred motion field. iterations - number of iterations the algorithm does at each pyramid level. poly_n - size of the pixel neighborhood used to find polynomial expansion in each pixel; larger values mean that the image will be approximated with smoother surfaces, yielding more robust algorithm and more blurred motion field, typically poly_n =5 or 7. poly_sigma - standard deviation of the Gaussian that is used to smooth derivatives used as a basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a good value would be poly_sigma=1.5.

i did not understand how to use the flow matrix! What is it containing!?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-08-05 01:56:41 -0600

Ziyou gravatar image

flow.at<vec2f>(i,j)[0] means x component of the flow at the position (i,j); flow.at<vec2f>(i,j)[1] means y component of the flow at the position (i,j);

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-30 00:48:49 -0600

Seen: 1,096 times

Last updated: Aug 05 '14