1

使用 boxFilter 函数时出现以下错误:

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

这是代码片段:

//After downloading image from url, I process it as follows
imgcv = cv2.cvtColor(np.asarray(im), cv.CV_RGB2YCrCb)
#Get the channel 0 
imgcv1 = cv2.split(imgcv)[0] 
cv2.boxFilter(imgcv1, 1, 7, data, (1,1), 0, cv2.BORDER_DEFAULT)

它说参数不是元组。如何把它变成元组?我试图搜索很多但没有有用的结果。我是openCV和python的初学者。这是过滤器的定义:

cv2.boxFilter(src, ddepth, ksize[, dst[, anchor[, normalize[, borderType]]]]) → dst
Parameters: 
    src – Source image.
    dst – Destination image of the same size and type as src .
    ksize – Smoothing kernel size.
    anchor – Anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center.
    normalize – Flag specifying whether the kernel is normalized by its area or not.
    borderType – Border mode used to extrapolate pixels outside of the image.

提前致谢。

4

1 回答 1

2

我让它工作:

cv2.boxFilter(imgcv1, 0, (7,7), imgcv1, (-1,-1), False, cv2.BORDER_DEFAULT)

我将点数设为 7 而不是 (7,7),并且将深度设为 1 而不是 0。Python 也将 False 作为布尔值,我尝试用 0 代替它。啊,很多错误。希望有一天它可以帮助像我这样的其他初学者。

于 2013-03-18T19:46:40.387 回答