http://docs.opencv.org/3.1.0/d7/d8b/tutorial_py_lucas_kanade.html#gsc.tab=0
calcOpticalFlowFarneback
Computes a dense optical flow using the Gunnar Farneback’s algorithm.
-
double
pyrScale, int
levels, int
winsize, int
iterations, int
polyN, double
polySigma, int
flags
)
-
Python:
cv2.
calcOpticalFlowFarneback
(prevImg, nextImg, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags
[, flow
]
) → flow
-
Parameters: - prevImg – First 8-bit single-channel input image. 输入单通道图片
- nextImg – Second input image of the same size and the same type asprevImg . 下一帧图片。
- flow – Computed flow image that has the same size as prevImg and typeCV_32FC2 .输出的双通道flow
- pyrScale – Parameter specifying the image scale (<1) to build pyramids for each image. pyrScale=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.均值窗口大小,越大越能denoise并且能够检测快速移动目标,但是会引起模糊运动区域。
- iterations – Number of iterations the algorithm does at each pyramid level.迭代次数。
- polyN – 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, polyN =5 or 7.
- polySigma – Standard deviation of the Gaussian that is used to smooth derivatives used as a basis for the polynomial expansion. ForpolyN=5 , you can set polySigma=1.1 . For polyN=7 , a good value would be polySigma=1.5 .