Computes a dense optical flow using the Gunnar Farneback<U+2019>s algorithm.
farneback(image1, image2, pyr_scale = 0.5, levels = 3, winsize = 43,
iterations = 3, poly_n = 7, poly_sigma = 1.5)
An Image
object.
An Image
object.
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.
Number of pyramid layers including the initial image; levels = 1 means that no extra layers are created and only the original images are used.
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.
Number of iterations the algorithm does at each pyramid level.
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.
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.
A matrix with the same number of rows and columns as the original images, and two layers representing the x and y components of the optical flow for each pixel of the image.
Farneb<U+00E4>ck G. Two-Frame Motion Estimation Based on Polynomial Expansion. In: Bigun J, Gustavsson T, editors. Image Analysis. Springer Berlin Heidelberg; 2003. pp. 363<U+2013>370. doi:10.1007/3-540-45103-X_50