且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在opencv 2DFilter中使用自定义内核-导致崩溃...卷积如何?

更新时间:2022-03-15 00:03:07

应该发布断言错误,它可以帮助别人回答您​​,而不是质疑为什么是崩溃。无论如何,我在下面发布了卷积filter2D的可能错误和解决方案。

The assertion error should be posted which would help someone to answer you other than questioning why is the crash. Anyways, I have posted below the possible errors and solution for convolution filter2D.

错误1:

OpenCV错误:cv :: countNo
nZero中的断言失败(src.channels()== 1&& func!= 0),文件C:\builds\2_4_PackSlave-win32-vc12-shared \opencv\modules\core\src\st
at.cpp,第549行

解决方案:输入图像和内核应该是灰度的。您可以在标记中使用标志0。 (例如, cv :: imread( kernel.png,0)可以将图像读取为灰度图像。)如果要将不同的内核应用于不同的通道,请使用分割图像到单独的色彩平面split()并分别处理它们。

Solution : Your input Image and the kernel should be grayscales. You can use the flag 0 in imread. (ex. cv::imread("kernel.png",0) to read the image as grayscale.) If you want to apply different kernels to different channels, split the image into separate color planes using split() and process them individually.

我看不到除了可能崩溃的过时错误以外的任何内容。内核大小应该为奇数,并且您的内核映像为11X11很好。如果仍然崩溃,请提供更多信息以帮助您。

I don't see anything other than the obove error that may crash. Kernel size should in odd numbers and your kernel image is 11X11 which is fine. If it stills crashes kindly provide more information in order to help you out.