Search code examples
javaopencvjavacv

JavaCV doesn't start


First thing: I'm not a native english speaker so i try to do my best. Im trying to use JavaCV but it doesn't work. I get the error:

OpenJDK 64-Bit Server VM warning: You have loaded library /usr/lib/libtbb.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
    at com.googlecode.javacpp.Loader.load(Loader.java:586)
    at com.googlecode.javacpp.Loader.load(Loader.java:540)
    at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:134)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at com.googlecode.javacpp.Loader.load(Loader.java:561)
    at com.googlecode.javacpp.Loader.load(Loader.java:540)
    at com.googlecode.javacv.cpp.opencv_core$CvArr.<clinit>(opencv_core.java:156)
    at Main.main(Main.java:18)
    ... 5 more
Caused by: java.lang.UnsatisfiedLinkError: /tmp/javacpp22248052399215/libjniopencv_core.so: libopencv_core.so.2.4: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:700)
    ... 14 more

i installed OpenCV with this tutorial: https://udallascs.wordpress.com/2014/03/30/adding-opencv-and-configuring-to-work-with-eclipse-and-java/

and here is the source code:

import com.googlecode.javacv.cpp.opencv_core.IplImage;

//import static com.googlecode.javacv.cpp.opencv_core.*; 
//import static com.googlecode.javacv.cpp.opencv_imgproc.*; 
//import static com.googlecode.javacv.cpp.opencv_highgui.*;

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;


public class Main {

public static void main(String s[]) {
    try {
    BufferedImage bi = ImageIO.read(new File("/home/arjan/Desktop/HelloWorld.jpg"));
    IplImage img = IplImage.createFrom(bi);
    // cvShowImage("Hello-World",img);
    // cvSmooth(img, img, CV_GAUSSIAN, 13);
    // cvShowImage("Blur-Image",img); 
    // cvWaitKey();
    // cvReleaseImage(img); 

    }catch (Exception ex) {ex.printStackTrace();}
}

}

I'm using arch linux and also installed OpenCV with pacman here is a image of the jars I use picture of jar files


Solution

  • Follow @m-prokhorov. The error message you posted says clearly:

    Caused by: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path.

    Now you can lookup that phrase in an internet search engine you trust or even SO itself: Getting JavaCV 0.9 platform binaries to download automatically with SBT .