我有这段opencv代码,它对我在某个页面上找到的图像进行卷积。我想尝试一下,但是它会出现以下错误,而我不太了解openCV。我需要帮助。
错误:OpenCV错误:在cv :: Mat :: locateROI的文件C:\ build \ master_winpack-bindings-win64-vc14-static \ opencv \ modules \ core \ src \ matrix.cpp的第949行中断言失败(dims <= 2 && step [0]> 0)。
错误:OpenCV错误:在cv :: Mat :: locateROI的文件C:\ build \ master_winpack-bindings-win64-vc14-static \ opencv \ modules \ core \ src \ matrix.cpp的第949行中断言失败(dims <= 2 && step [0]> 0)。
public class main {
public static void main (String [ ] args) {
System.out.println ("hola");
try {
int kernelSize = 3;
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
Mat source = Imgcodecs.imread("logo.png", Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
Mat destination = new Mat(source.rows(),source.cols(),source.type());
Mat kernel = new Mat(kernelSize,kernelSize, CvType.CV_32F){
{
put(0,0,0);
put(0,1,0);
put(0,2,0);
put(1,0,0);
put(1,1,1);
put(1,2,0);
put(2,0,0);
put(2,1,0);
put(2,2,0);
}
};
Imgproc.filter2D(source, destination, -1, kernel);
Imgcodecs.imwrite("original.jpg", destination);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
}