opencv:TypeError:mask不是数字元组

2024-04-29 04:02:45 发布

您现在位置:Python中文网/ 问答频道 /正文

嘿,我在使用掩码向矩阵添加标量时遇到错误TypeError: mask is not a numerical tuple。mask变量在这里打印:

(15.0, array([[  0, 255,   0, ...,   0,   0,   0],
       [  0,   0,   0, ...,   0,   0,   0],
       [  0,   0, 255, ...,   0,   0,   0],
       ..., 
       [255, 255, 255, ...,   0,   0,   0],
       [255, 255, 255, ...,   0,   0,   0],
       [  0, 255, 255, ...,   0,   0,   0]], dtype=uint8))

这就是错误本身:

Traceback (most recent call last):
  File "/home/clime/mrak/motionpaint/motion_painter.py", line 97, in process_frame
    self.alphas = cv2.add(self.alphas, self.alpha_increment, mask=mask)
TypeError: mask is not a numerical tuple

我就是这样得到面具的:

    diff = cv2.absdiff(self.prevFrame, smoothedFrame)

    # convert difference to grayscale.
    greyDiff = cv2.cvtColor(diff, cv2.COLOR_RGB2GRAY)

    # grayscale to black and white (i.e. false and true)
    mask = cv2.threshold(greyDiff, self.threshold, 255, cv2.THRESH_BINARY)

Tags: andtoselfis错误notdiffmask