Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
392 views
in Technique[技术] by (71.8m points)

python - "System error: new style getargs format but argument is not a tuple" when using cv2.blur

I am just trying to apply a filter to an image using cv2, the opencv python bindings. Here is what my code look like:

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

It's almost copy-and-paste from the documentation. However, it just doesn't work, with no more trace than this message:

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

The same error occurs with GaussianBlur, but not with medianBlur. Any thoughts?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For cv2.blur, you need to give ksize as a tuple of two elements , like (2,2). But for medianBlur, ksize = 3 is sufficient. It will deduct a square kernel from it.

So make code like this :

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

Hope it will work!!!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...