I am having following error when I use the boxFilter function:

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

Here is the code sniplet:

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

It says the argument is not a tuple. How to make it into tuples? I tried to search a lot but no helpful results. I am a beginner in openCV and in python. Here is the definition of the filter:

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.

Thanks in advance.

有帮助吗?

解决方案

I got it working:

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

I was giving the points as 7 instead of (7,7) and was giving depth as 1, instead of 0. Also Python takes False as Boolean and I was trying 0 in place of it. Aah, lots of mistakes. Hope it helps some other beginner like me someday.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top