JavaCV无法启动

时间:2017-09-11 12:37:02

标签: java opencv javacv

第一件事:我不是母语为英语的人,所以我尽力做到最好。 我试图使用JavaCV,但它不起作用。我收到错误:

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

我在本教程中安装了OpenCV: https://udallascs.wordpress.com/2014/03/30/adding-opencv-and-configuring-to-work-with-eclipse-and-java/

这是源代码:

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();}
}

}

我使用arch linux并且还使用pacman安装了OpenCV 这是我使用的picture of jar files

罐子的图像

1 个答案:

答案 0 :(得分:2)

关注@ m-prokhorov。 您发布的错误消息清楚地说明了:

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

现在,您可以在您信任的互联网搜索引擎中查找该词组,甚至是SO本身:Getting JavaCV 0.9 platform binaries to download automatically with SBT