# Input parameters for Farneback optical flow

I'm going through Farneback optical flow estimation and, in particular, through the following line

cuda::FarnebackOpticalFlow::create(int numLevels=5, double pyrScale=0.5, bool fastPyramids=false, int winSize=13, int numIters=10, int polyN=5, double polySigma=1.1, int flags=0)


creating the Farneback estimator. It seem I could not find a comprehensive documentation for the input parameters. Although I understand most of them, two are still not clear to me:

bool fastPyramids


and

double polySigma


Concerning the former, what is the fast pyramids approach? Concerning the latter, I have found that

polySigma is the standard deviation of the Gaussian that is used to smooth derivatives used as a basis for the polynomial expansion; for polyN=5, you can set polySigma=1.1, for polyN=7, a good value would be polySigma=1.5.

In which way are we smoothing derivatives?

Thank you for any help.

edit retag close merge delete

Sort by » oldest newest most voted

After some search, I think I can now answer my own questions.

What is the fast pyramids approach?

On browsing the OpenCV source code, in optflowgf.cpp, I found the following lines:

    // Crop unnecessary levels
double scale = 1;
int numLevelsCropped = 0;
for (; numLevelsCropped < numLevels_; numLevelsCropped++)
{
scale *= pyrScale_;
if (size.width*scale < min_size || size.height*scale < min_size)
break;
}


The above lines crop the pyramid levels which are smaller than min_size x min_size. Furthermore, min_size is defined, still in optflowgf.cpp, as

const int min_size = 32;


Finally, again in optflowgf.cpp, I found

    if (fastPyramids_)
{
// Build Gaussian pyramids using pyrDown()
pyramid0_.resize(numLevelsCropped + 1);
pyramid1_.resize(numLevelsCropped + 1);
pyramid0_ = frames_;
pyramid1_ = frames_;
for (int i = 1; i <= numLevelsCropped; ++i)
{
pyrDown(pyramid0_[i - 1], pyramid0_[i]);
pyrDown(pyramid1_[i - 1], pyramid1_[i]);
}
}


I would then say that fast pyramids skip too small pyramid levels.

In which way are we smoothing derivatives?

From Farneback's paper "Two-Frame Motion Estimation Based on Polynomial Expansion", my understanding is that the window function involved in eq. (12) is a Gaussian. From this point of view, polyN x polyN is the size of the window, while polySigma is the standard deviation of the Gaussian.

more

Official site

GitHub

Wiki

Documentation