无法用java打开cv加载图片

Jo_*_*ast 13 java opencv

我尝试将所有库放在我的项目中(它描述为解决这个问题的方法),但仍然存在同样的问题.

Mat m = Highgui.imread("Koala.jpg");

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_1(Ljava/lang/String;)J
    at org.opencv.highgui.Highgui.imread_1(Native Method)
    at org.opencv.highgui.Highgui.imread(Highgui.java:352)
    at Open.main(Open.java:26)
Run Code Online (Sandbox Code Playgroud)

小智 22

我得到了同样的错误,以下行为我工作.

的System.loadLibrary(Core.NATIVE_LIBRARY_NAME);


小智 1

Java 目前无法看到 OpenCV,因此会出现链接错误。

我使用的是 Mac,因此我链接到它在我的驱动器上的位置:

System.load( "/opt/local/share/OpenCV/java/libopencv_java246.dylib" )
Run Code Online (Sandbox Code Playgroud)

您也许还可以将 JAR 直接包含在项目的 lib 文件夹中,但我通过指向 dylib 获得了成功。