OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 03 Feb 2020 08:44:39 -0600Input parameters for Farneback optical flowhttp://answers.opencv.org/question/225634/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.
Sat, 01 Feb 2020 02:50:34 -0600http://answers.opencv.org/question/225634/input-parameters-for-farneback-optical-flow/Answer by JackOLantern for <p>I'm going through Farneback optical flow estimation and, in particular, through the following line</p>
<pre><code>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)
</code></pre>
<p>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:</p>
<pre><code>bool fastPyramids
</code></pre>
<p>and</p>
<pre><code>double polySigma
</code></pre>
<p>Concerning the former, what is the fast pyramids approach?
Concerning the latter, I have found that</p>
<blockquote>
<p>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.</p>
</blockquote>
<p>In which way are we smoothing derivatives?</p>
<p>Thank you for any help.</p>
http://answers.opencv.org/question/225634/input-parameters-for-farneback-optical-flow/?answer=225744#post-id-225744After 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](http://www.diva-portal.org/smash/get/diva2:273847/FULLTEXT01.pdf)", 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.
Mon, 03 Feb 2020 08:44:39 -0600http://answers.opencv.org/question/225634/input-parameters-for-farneback-optical-flow/?answer=225744#post-id-225744