gpt4 book ai didi

python - "System error: new style getargs format but argument is not a tuple"使用 cv2.blur 时

转载 作者:IT老高 更新时间:2023-10-28 22:12:04 25 4
gpt4 key购买 nike

我只是想使用 cv2(opencv python 绑定(bind))对图像应用过滤器。这是我的代码的样子:

im = cv2.imread('./test_imgs/zzzyj.jpg')
cv2.imshow('Image', cv2.blur(im, 2)
cv2.waitKey(0)

它几乎是从 documentation 复制粘贴.但是,它只是不起作用,没有比这条消息更多的痕迹:

SystemError: new style getargs format but argument is not a tuple

GaussianBlur 也会出现同样的错误,但中值Blur 不会。有什么想法吗?

最佳答案

对于 cv2.blur,您需要将 ksize 作为两个元素的元组,例如 (2,2)。但是对于 medianBlur,ksize = 3 就足够了。它会从中减去一个平方核。

所以编写这样的代码:

im = cv2.imread('./test_imgs/zzzyj.jpg')
cv2.imshow('Image', cv2.blur(im, (3,3)))
cv2.waitKey(0)
cv2.destroyAllWindows()

希望能成功!!!

关于python - "System error: new style getargs format but argument is not a tuple"使用 cv2.blur 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13225525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com