OpenCV, can't load library in Eclipse [Mavericks 10.9.2]

asked 2014-03-17 04:13:59 -0600

updated 2014-03-17 04:25:23 -0600

berak gravatar image

Hello to everyone, I'm an italian noob and I'm trying to understand something about OpenCV , for my master thesis. I'm sorry for my english but I'll try to explain myself as good as possible. However, this is my problem:

I downloaded the Tegra Android Development Pack here. After the installation I have Eclipse with OpenCV and I'm able to test OpenCV's samples on my Android phone. However, if I want to create a new project I have problems with Libraries. I googled a lot but I can't fix my problem. First of all I created a simple Java single-class project. The class is named "Start" and here is the code:

import org.opencv.core.Core;

import org.opencv.core.CvType; import org.opencv.core.Mat;

public class Start {

public static void main(String[] args){
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    Mat mat = Mat.eye(3,3, CvType.CV_8UC1);
    System.out.println("mat = "+ mat.dump());
}

}

After that I "set up" the libraries: 1) open eclipse -> preferences -> Java -> Build path -> User Libraries 2) click "new" and type "OpenCV_2.4.5" 3) click "add external jars" 4) go to \sdk\java\bin\ and select my "opencv library 2.4.5.jar"

Then: 1) double clicked on my project and go to "properties" 2) go to "Java build path" 3) go to "Libraries" 4) go to "add Library" -> "user library" and select "OpenCV_2.4.5"

After these steps All the imports are ok and I don't have errors. However, when I run the application as "Java application", I have this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java245 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1764)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1044)
at Start.main(Start.java:9)

On the internet I found this error and people tell to set the "native library location" to something like opencv\build\java\x86. However I don't have nothing under opencv\build and honestly, I don't know whether the real problem is this one.

Thank you for the help

edit retag flag offensive close merge delete