def __init__(self):
super(TargetFilterBGSub, self).__init__()
# background subtractor
#self._bgs = cv2.BackgroundSubtractorMOG()
#self._bgs = cv2.BackgroundSubtractorMOG2() # not great defaults, and need bShadowDetection to be False
#self._bgs = cv2.BackgroundSubtractorMOG(history=10, nmixtures=3, backgroundRatio=0.2, noiseSigma=20)
# varThreshold: higher values detect fewer/smaller changed regions
self._bgs = cv2.createBackgroundSubtractorMOG2(history=0, varThreshold=8, detectShadows=False)
# ??? history is ignored? Only if learning_rate is > 0, or...? Unclear.
# Learning rate for background subtractor.
# 0 = never adapts after initial background creation.
# A bit above 0 looks good.
# Lower values are better for detecting slower movement, though it
# takes a bit of time to learn the background initially.
self._learning_rate = 0.001
# elements to reuse in erode/dilate
# CROSS elimates more horizontal/vertical lines and leaves more
# blobs with extent in both axes [than RECT].
self._element_shrink = cv2.getStructuringElement(cv2.MORPH_CROSS,(5,5))
self._element_grow = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(7,7))
评论列表
文章目录