def foreground(self, image, smooth=False, grayscale=False):
"""
Extract foreground from background
:param image:
:param smooth:
:param grayscale:
:return:
"""
if smooth and grayscale:
image = self.toGrayscale(image)
image = self.smooth(image)
elif smooth:
image = self.smooth(image)
elif grayscale:
image = self.toGrayscale(image)
fgmask = self.fgbg.apply(image)
ret, mask = cv2.threshold(fgmask, 200, 255, cv2.THRESH_BINARY_INV)
mask_inv = cv2.bitwise_not(mask)
return mask_inv
评论列表
文章目录