【发布时间】:2016-08-15 06:28:15
【问题描述】:
从 Eclipse 执行时,代码运行良好。我正在为 UI 使用 OpenCV 2.4.11 和 JavaFX。当我从 Eclipse 导出可执行 Jar 并从 cmd 运行它时,出现以下异常:
我在 SO 和 OpenCV 论坛上关注了很多帖子(1、2、3、4)但是,似乎没有一个答案对我有帮助。
我已将 OpenCV jar 添加为库,并且本机库已链接到 /build/java/x64,如 SO 答案中所建议的那样。
异常发生在 System.loadLibrary(Core.Native_Library_Name),我检查了 Native_Library_Name 并且 OpenCV 版本与我在项目中导入的版本相同。
public class CustomFrame extends Application{
@Override
public void start(Stage primaryStage){
Group root = new Group();
Canvas canvas = new Canvas(1440, 840);
ImageView imageView = new ImageView();
imageView.setFitHeight(canvas.getHeight());
imageView.setFitWidth(canvas.getWidth());
new FrameController().startCamera(imageView);
root.getChildren().addAll(imageView, canvas);
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
public static void main(String[] args)
{
// load the native OpenCV library
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
launch(args);
}
}
如果有人认为我遗漏了什么,请告诉我。
【问题讨论】:
-
既然你似乎已经找到了你的解决方案,我建议你还是看看我的。使用我的,您不必像在其他解决方案中那样指定任何绝对路径,一旦您将应用程序提供给其他用户或安装不同版本的 OpenCV,这显然会破坏您的调用。
标签: java eclipse opencv javafx executable-jar