Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gaussianBlurAsync error when using kSize values other than (7, 7) #310

Closed
Correct-Syntax opened this issue Dec 22, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@Correct-Syntax
Copy link

Describe the bug

Using values other than (7, 7) for the kSize in the gaussianBlurAsync method results in a crash.

To Reproduce
Steps to reproduce the behavior:

  1. Use the code from https://github.com/rainyl/opencv_dart/blob/main/packages/opencv_core/example/lib/main.dart as your project.
  2. Change blur = await cv.gaussianBlurAsync(im, (7, 7), 2, sigmaY: 2); to blur = await cv.gaussianBlurAsync(im, (8, 8), 2, sigmaY: 2);
  3. When you select an image with the "Pick Image" button, it results in an error/crash.

If I set the kSize back to (7, 7) it works, but any other value doesn't.

Expected behavior
The blur method should not crash with values other than (7, 7).

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop:

  • OS: Windows 10

Additional context

The error:

Exception has occurred.
CvException (CvException(code: -215, msg:OpenCV(4.10.0) D:\a\opencv.full\opencv.full\opencv\modules\imgproc\src\smooth.dispatch.cpp:294: error: (-215:Assertion failed) ksize.width > 0 && ksize.width % 2 == 1 && ksize.height > 0 && ksize.height % 2 == 1 in function 'cv::createGaussianKernels'
) in cv::createGaussianKernels of file D:\a\opencv.full\opencv.full\opencv\modules\imgproc\src\smooth.dispatch.cpp:294)

Maybe this is related to #180?

@Correct-Syntax Correct-Syntax added the bug Something isn't working label Dec 22, 2024
@rainyl
Copy link
Owner

rainyl commented Dec 23, 2024

@Correct-Syntax Have you tried other odd values like (9, 9), (11, 9), (15, 15)? Please note that the kernel size of gaussianBlur must be ODD, refer to https://docs.opencv.org/4.x/d4/d86/group__imgproc__filter.html#gae8bdcd9154ed5ca3cbc1766d960f45c1

@Correct-Syntax
Copy link
Author

Correct-Syntax commented Dec 23, 2024

@rainyl Ah, I see. I'm used to the Python version of OpenCV where they evidently silently correct the values, not matter what is specified. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants