ips
ips

Reputation: 136

OpenCV 3.0.0 java.lang.UnsatisfiedLinkError in Eclipse

I am trying to set up Eclipse (Neon version) with OpenCV 3.0.0 and I ran into an issue. When I am loading an image, the code below:

Mat m = Imgcodecs.imread("newimage.jpg");

the following error is thrown:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_1(Ljava/lang/String;)J
    at org.opencv.imgcodecs.Imgcodecs.imread_1(Native Method)
    at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:82)
    at TestOpenCVFeats.main(TestOpenCVFeats.java:39)

Everything is set up according to this site Set up OpenCV for Java in Eclipse

Also added the path to java.library.path with:

export LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/usr/local/share/OpenCV/java

confirmed it is there with:

java -XshowSettings:properties

and to the $PATH variable.

Also added this command to JVM run configuration:

-Djava.library.path= "/usr/local/share/OpenCV/java"

Also tried with this line of code and without it:

System.loadLibrary("libopencv_java300");

The permissions for the files on the path /usr/local/share/OpenCV/java are:

-rwxr-xr-x 1 root root 831809 Srp  1  2015 libopencv_java300.so
-rwxr-xr-x 1 root root 300815 Srp  1  2015 opencv-300.jar

I have tried all possible combinations and still get the same error. I do not know what else I could try to make this work. The OpenCV works properly when I execute the c++ (Eclipse Luna) or python code. My operating system is Ubuntu 14.04.

Any help is much appreciated.

Upvotes: 1

Views: 8125

Answers (2)

Rakesh
Rakesh

Reputation: 1

If you want to configure OpenCV in windows using eclipse follow these steps:

  1. Download OpenCV 2.4.11 or any version from this link https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.11/opencv-2.4.11.exe/download
  2. Extract it.
  3. Open eclipse.
  4. Create a new Java Project.
  5. Add the OpenCV jar.

    • Right click on the project.
    • Choose Build Path.
    • Click Configure Build Path.
    • Click Libraries.
    • Add External Jars.
    • Open OpenCV extracted folder.
    • Open build/java/
    • Choose opencv-2411.jar and open.
    • Click Apply.
    • Click Ok.
  6. Add Native Library.

You can use OpenCv Native Library by:

  • Adding the native library to your opencv jar.
  • Point to Native Library in java by using System.load() methods, but make sure you have to specify the native library path.

Adding the native library to your opencv jar

  • Right click on the project.
  • Choose Build Path.
  • Click Configure Build Path.
  • Click Libraries.
  • Expand opencv jar.
  • Click Native Library.
  • Click Edit button in the right side panel.
  • Click External Folde.
  • Open OpenCV extracted folder.
  • Open build/java/x64.(if your OS is 64bit choose x64 else x86)
  • Click Ok.
  • Click Apply.
  • Click Ok.

Point to Native Library in java class

  • Pass the location of "opencv_java2411.dll" from opencv\build\java\x64 to System.load("Path of your opencv dll")

Upvotes: 0

ips
ips

Reputation: 136

Ok, well, found the solution. This line of code needs to be added in main:

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

Upvotes: 5

Related Questions