Ask Your Question
0

Input parameters for Farneback optical flow

asked 2020-02-01 02:50:34 -0600

JackOLantern gravatar image

updated 2020-02-01 04:36:22 -0600

berak gravatar image

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-02-03 08:44:39 -0600

JackOLantern gravatar image

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_[0] = frames_[0];
        pyramid1_[0] = frames_[1];
        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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-02-01 02:50:34 -0600

Seen: 1,259 times

Last updated: Feb 03 '20