我正在使用opencv v2.4.13捕获图像并打开图像文件。但是当我运行它时会显示错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/opencv/core/Core
at com.ismo.First.<clinit>(First.java:33)
这是引发错误的代码:
public class First {
static ImgShow imgShowOrigin = new ImgShow("WELCOME");
static String srcPath = "C:/Users/JAFFAR/Pictures/Testing";
static {
// Load Opencv native library
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
public static void main(String[] args) {
System.out.println("Start app...");
openImage();
System.out.println("Done!");
}
public static void openImage() {
Mat m = Highgui.imread(srcPath + "img1.jpg");
Size imgSize = m.size();
Imgproc.resize(m, m, new Size(500, imgSize.height * 500 / imgSize.width), 1.0, 1.0, INTER_CUBIC);
imgShowOrigin.show(m);
}
}
答案 0 :(得分:0)
当您尝试访问不在类路径中的类时,发生NoClassDefFoundError。因此,您需要确保在类路径中有OpenCV库。您可以从OpenCV maven页上获取它。