Ask Your Question
0

medianBlur from imgproc not working with python bindings?

asked 2012-11-20 10:56:59 -0600

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-03-13 23:20:55 -0600

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)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-11-20 10:56:59 -0600

Seen: 2,898 times

Last updated: Mar 13 '18