cv2.VideoCapture()
0 代表使用摄像头 或者输入路径读视频
cv2.calcOpticalFlowFarneback()cv2. calcOpticalFlowFarneback ( prev, next, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags ) → flow
- prev – first 8-bit single-channel input image.
- next – second input image of the same size and the same type as prev.
- flow – computed flow image that has the same size as prev and type CV_32FC2.
- pyr_scale – 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.
- 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.
- iterations – number of iterations the algorithm does at each pyramid level.
- poly_n – 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.
- poly_sigma – 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.
百度翻译。。:
沪指–第一位单通道输入图像。
下一–二输入图像相同的尺寸和类型上相同。
流–计算流动图像大小和类型相同,沪指cv_32fc2。
pyr_scale–参数,指定图像的尺度(<1)为每个图像建立金字塔;pyr_scale = 0.5意味着一个经典的金字塔,在每一层都比前一次小。
级别——包括初始图像在内的金字塔层的数量;级别= 1意味着不会创建额外的层,只使用原始图像。
winSize–平均窗口尺寸;较大的值增加算法的鲁棒性的图像噪声和快速运动检测更多的机会,但更模糊的运动场。
迭代——算法在每个金字塔级别上的迭代次数。
poly_n–大小用来找到每个像素的多项式展开的邻域;值越大,意味着它的形象将与平滑的表面近似,获得更强大的算法和更模糊的运动场,通常poly_n = 5或7。
poly_sigma–的高斯是用来平滑的衍生物作为多项式扩展的基础标准偏差;对poly_n = 5,你可以设置poly_sigma = 1.1,为poly_n = 7,一个好的价值将poly_sigma = 1.5。
旗– 操作标志,可以是以下内容的组合: