opencv-python: 不是一个numpy数组
我想用当前的数组作为模糊操作后得到的输出数组,但我遇到了这个错误:
TypeError: <unknown> is not a numpy array
我已经检查过了,两个数组的大小和类型都是一样的,我不明白为什么会出现这个问题。
代码的一部分:
previous = np.zeros((frameHeight,frameWidth,3),np.uint8) #blank image with 640x480 and 3 channels
difference = np.zeros((frameHeight,frameWidth,3),np.uint8)
current = np.zeros((frameHeight,frameWidth,3),np.uint8)
while True:
# Capture a frame
flag,frame = capture.read()
cv2.flip(frame, flipCode=1)
# Difference between frames
cv2.blur(frame, current, (15,15))
2 个回答
0
可能你是用 cv.CreateImage 来打开图片的,而不是用 cv2.imread。只有在你用 imread 打开图片之后,才能使用 imwrite。
2
关于cv2.blur
这个函数的参数,具体内容可以在文档中查看,它们如下:
cv2.blur(src, ksize[, dst[, anchor[, borderType]]]) → dst
所以,我想你是想说
current= cv2.blur(frame, (15,15))