线程“main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_java2410

时间:2015-03-30 21:49:16

标签: java opencv

我正在尝试使用opencv版本2410捕获相机但这个例外 出现虽然路径是正确的 我试图打开相机并从相机捕捉视频,但这个异常出现了 我在许多网站上搜索过但没有相同的词语

  
    

netbeans 8.0.2

  

我该如何解决?

output
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java2410 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at videocap.VideoCap.main(VideoCap.java:20)
Java Result: 1

代码

VideoCap.java
package videocap;
import org.opencv.core.*;
import org.opencv.highgui.Highgui;        
import org.opencv.highgui.VideoCapture;     

 public class VideoCap {


 public static void main (String args[]){
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    VideoCapture camera = new VideoCapture(0);

    if(!camera.isOpened()){
        System.out.println("Error");
    }
    else {
        Mat frame = new Mat();
        while(true){
            if (camera.read(frame)){
                System.out.println("Frame Obtained");
                System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height());
                Highgui.imwrite("camera.jpg", frame);
                System.out.println("OK");
                break;
            }
        }   
    }
    camera.release();
}

}

enter image description here enter image description here enter image description here enter image description here

1 个答案:

答案 0 :(得分:1)

为了包含本机库,我们需要在netbeans中添加以下步骤

 ==>Right click on the Project
 ==>Properties
 ==>Click on RUN
 ==>VM Options : -Djava.library.path="C:\Your Directory where Dll is present"
 ==>Ok