本文转自:http://blog.csdn.net/Scythe666/article/details/38147051
这是(II)中的Mat版本,特别注意一下accumulateWeighted这个函数的用法。
我将官方文档中的函数说明贴出来:
accumulateWeighted
Updates a running average.
-
C++:
void
accumulateWeighted
(InputArray
src, InputOutputArray
dst, double
alpha, InputArray
mask=noArray()
)
-
Python:
cv2.
accumulateWeighted
(src, dst, alpha
[, mask
]
) → None
-
C:
void
cvRunningAvg
(const CvArr*
image, CvArr*
acc, double
alpha, const CvArr*
mask=NULL
)
-
Python:
cv.
RunningAvg
(image, acc, alpha, mask=None
) → None
-
Parameters: - src – Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
- dst – Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
- alpha – Weight of the input image.
- mask – Optional operation mask.
The function calculates the weighted sum of the input image src and the accumulator dst so that dst becomes a running average of a frame sequence:
That is, alpha regulates the update speed (how fast the accumulator “forgets” about earlier images). The function supports multi-channel images. Each channel is processed independently.
See also