【发布时间】:2020-06-03 01:47:45
【问题描述】:
当我运行下面的代码时,我得到了下面的错误,但它以前工作过,我不确定 Eclipse 得到了什么并且不再好
错误:无法初始化主类 src.convolution 引起:java.lang.NoClassDefFoundError: org/opencv/core/Mat
package src;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class convolution {
public static void main( String[] args ) {
try {
int kernelSize = 9;
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
Mat source = Imgcodecs.imread("C:/Users/B & B/Desktop/ProcIMG/grayscale.jpg", Imgcodecs.IMREAD_GRAYSCALE);
Mat destination = new Mat(source.rows(),source.cols(),source.type());
Mat kernel = new Mat(kernelSize,kernelSize, CvType.CV_32F){
{
put(0,0,-3);
put(0,1,-3);
put(0,2,-3);
put(1,0-3);
put(1,1,0);
put(1,2,-3);
put(2,0,5);
put(2,1,5);
put(2,2,5);
}
};
Imgproc.filter2D(source, destination, -1, kernel);
Imgcodecs.imwrite("C:/Users/B & B/Desktop/ProcIMG/output.jpg", destination);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
}
【问题讨论】:
-
我已经尝试了很多 Deepak Jain 中的“解决方案”,不幸的是没有奏效。