First time here? Check out the FAQ!

Ask Your Question
0

medianBlur from imgproc not working with python bindings?

asked Nov 20 '12

nuriah gravatar image

Hi there, I don't really know if this is the right place to ask since I am using a windows 64 bit beta version of the openCV python bindings but here we go:

When using a numpy array as source I get a type error

----> 1 dest = cv2.medianBlur(src,3)
TypeError: src is not a numpy array

When using a matrix mat created via cv.CreateMat, I get the following weird error

----> 1 dest = cv2.medianBlur(src,3)
error: ..\..\..\OpenCV-2.4.3\modules\imgproc\src\smooth.cpp:1679: error: (-210)

For testing purposes I tried out the cv2.Laplacian which works just fine with 2 matrices created via cv.CreateMat as source and destination.

If anyone could point me in a direction where to search for the error I would be glad!

Environment data: Windows 7 64bit, Python 2.7, OpenCV 2.4.3

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Mar 14 '18

The issue is likely your source type. I had the same issue; from the docstring, "src input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be . CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U"

try something like

dest = cv2.medianBlur(src.astype(np.float32),3)

Preview: (hide)

Question Tools

Stats

Asked: Nov 20 '12

Seen: 2,996 times

Last updated: Mar 13 '18