OpenCV Error: Assertion failed (ksize.width > ...... for GaussianBlur

Mr.Fu picture Mr.Fu · Dec 17, 2014 · Viewed 12.1k times · Source

when I call Imgproc.GaussianBlur(dst, dst ,new Size(3,3),1); in my application it works perfectly fine. As soon as I increase the kernel size to new Size(4,4) or else I get an

OpenCV Error: Assertion failed (ksize.width > 0 && ksize.width % 2 == 1 && ksize.height > 0 && ksize.height % 2 == 1) in cv::createGaussianFilter, file

........\opencv\modules\imgproc\src\smooth.cpp, line 816 Caused by: CvException [org.opencv.core.CvException: cv::Exception: ........\opencv\modules\imgproc\src\smooth.cpp:816: error: (-215) ksize.width > 0 && ksize.width % 2 == 1 && ksize.height

0 && ksize.height % 2 == 1 in function cv::createGaussianFilter ] at org.opencv.imgproc.Imgproc.GaussianBlur_1(Native Method) at org.opencv.imgproc.Imgproc.GaussianBlur(Imgproc.java:533)

Can please someone put me on the right track for this? I have no idea where/what to look for this.

Thx.

Answer

Hichamov picture Hichamov · Dec 17, 2014

As I understood from the trace, you are only allowed to use new Size(x,y) where x and y are odd