OpenCV + Java = UnsatisfiedLinkError [英] OpenCV + Java = UnsatisfiedLinkError
问题描述
我需要从我的USB网络摄像头捕获视频流,为此我使用Opencv 2.4.6进行Java开发。我按照此处中列出的步骤进行操作
I need capture a video stream from my USB webcam, for this i use Opencv 2.4.6 for developing in Java. I follow the steps listed in here
我将C:\ openncv \ build \ java \ x64目录添加到我的系统路径中,并在我的库中包含opencv-246.jar文件关于ECLIPSE。当你运行解释时
I add the "C:\opencv\build\java\x64" dir to my System PATH and include the "opencv-246.jar" file into my libraries on ECLIPSE. When y run the explame
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class Main {
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat m = Mat.eye(3, 3, CvType.CV_8UC1);
System.out.println("m = " + m.dump());
}
}
我得到
m = [1, 0, 0;
0, 1, 0;
0, 0, 1]
OK =)
但是当我运行时
import org.opencv.highgui.VideoCapture;
public class Main {
public static void main(String[] args) {
VideoCapture vc = new VideoCapture(0);
if(vc.isOpened()){
System.out.println("Works!");
}
}
}
我得到
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.highgui.VideoCapture.n_VideoCapture(I)J
at org.opencv.highgui.VideoCapture.n_VideoCapture(Native Method)
at org.opencv.highgui.VideoCapture.<init>(VideoCapture.java:113)
at Main.main(Main.java:5)
我添加所有包含的路线:
i add all the routes containes in:
C:\ openncv \ build \ x64 \ vc10
C:\opencv\build\x64\vc10
one by一个,但不起作用。
one by one,but doesn`t work.
最后我创建一个名为OPENCV_DIR的变量,其中包含C:\ opencv \ build \ x64 \ vc10但仍然得到UnsatisfiedLinkError。
Finally i create a variable called OPENCV_DIR with C:\opencv\build\x64\vc10 but still getting UnsatisfiedLinkError.
请帮助我!
推荐答案
在你的第二个例子中,你跳过这一行
in your second example , you skipped this line
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
所以opencv libs没有加载,UnsatisfiedLinkError等......
so the opencv libs werent loaded, UnsatisfiedLinkError, etc...
:
感谢@Jishnu Prathap突出显示java.library路径问题,如果遇到问题设置,你可以仍然尝试使用java包装器的绝对路径,所以/ dll / dylib就像:
thanks to @Jishnu Prathap for highlighting the java.library path issue, if you run into problems setting that, you can still try to use an absolute path to the java wrapper so/dll/dylib like:
System.load("/path to/our/java_wrapper");
这篇关于OpenCV + Java = UnsatisfiedLinkError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!