opencv-python:不是numpy数组

2024-10-01 13:39:08 发布

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

我想使用当前数组作为在帧图像中进行的模糊操作的输出数组,我得到这个错误:

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))

Tags: 图像is错误npzerosnot数组current
2条回答

可能您已经使用cv.CreateImageinstread ofcv2.imread打开了图像 只有使用imread打开图像时,才能使用imwrite。

in the documentation所述,cv2.blur的参数如下:

cv2.blur(src, ksize[, dst[, anchor[, borderType]]]) → dst

所以,我想你是说

current= cv2.blur(frame, (15,15))

相关问题 更多 >