Java opencv4android中的filter2d
我正在尝试使用filter2d在opencv4android中编写一个简单的代码。 但是在调用了函数'filter2d'之后,在目标mat中,我得到了零(它没有正确运行函数) 结果应该是:Java opencv4android中的filter2d,java,android,opencv,Java,Android,Opencv,我正在尝试使用filter2d在opencv4android中编写一个简单的代码。 但是在调用了函数'filter2d'之后,在目标mat中,我得到了零(它没有正确运行函数) 结果应该是: 0.3750 0.5000 0.5000 0.5000 0.3750 0 0 0 0 0 0 0 0 0 0 0
0.3750 0.5000 0.5000 0.5000 0.3750
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
-0.3750 -0.5000 -0.5000 -0.5000 -0.3750
我尝试更改源代码和内核的深度/类型,但没有帮助
这是我的密码:
Mat sourceMat = new Mat(5, 5, CvType.CV_32F);
Mat convMat = new Mat(3, 3, CvType.CV_32F);
Mat destMat = Mat.zeros(5, 5, CvType.CV_32F);
sourceMat.put(0,0,1);
sourceMat.put(0,1,1);
sourceMat.put(0,2,1);
sourceMat.put(0,3,1);
sourceMat.put(0,4,1);
sourceMat.put(1,0,1);
sourceMat.put(1,1,1);
sourceMat.put(1,2,1);
sourceMat.put(1,3,1);
sourceMat.put(1,4,1);
sourceMat.put(2,0,1);
sourceMat.put(2,1,1);
sourceMat.put(2,2,1);
sourceMat.put(2,3,1);
sourceMat.put(2,4,1);
sourceMat.put(3,0,1);
sourceMat.put(3,1,1);
sourceMat.put(3,2,1);
sourceMat.put(3,3,1);
sourceMat.put(3,4,1);
sourceMat.put(4,0,1);
sourceMat.put(4,1,1);
sourceMat.put(4,2,1);
sourceMat.put(4,3,1);
sourceMat.put(4,4,1);
convMat.put(0,0, 0.125);
convMat.put(0,1, 0.5);
convMat.put(0,2, 0.125);
convMat.put(1,0, 0);
convMat.put(1,1, 0);
convMat.put(1,2, 0);
convMat.put(2,0, -0.125);
convMat.put(2,1, -0.5);
convMat.put(2,2, -0.125);
Imgproc.filter2D(sourceMat, destMat, sourceMat.depth(), convMat);
谁能告诉我这里有什么问题吗?我做错什么了吗 这里没什么问题。OpenCV结果对于filter2d函数中使用的默认边界处理模式是正确的
您需要将最后一个
borderType
参数设置为Imgproc.BORDER\u常量
,以获得预期结果。您好!我想给你发一封关于自由职业者机会的电子邮件。如果你有兴趣,请给我留言。