java.lang.UnsatisfiedLinkError / tmp / javacpp94368173067 / libopencv_core.so.2.4:无法打开共享对象文件:没有这样的文件或目录

时间:2013-08-01 11:10:09

标签: java opencv ubuntu javacv

我使用javacv编写了java中的运动检测代码,它完全在Windows上运行,但在Ubuntu 13.04中它显示错误,请为此建议解决方案,我附加代码

代码

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo;

/**
 *
 * @author Admin
 */
import com.googlecode.javacpp.Loader;
import com.googlecode.javacv.*;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_calib3d.*;
import static com.googlecode.javacv.cpp.opencv_objdetect.*;

public class Demo {
    public static void main(String[] args) throws Exception {
        OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
        grabber.start();

        IplImage frame = grabber.grab();
        IplImage image = null;
        IplImage prevImage = null;
        IplImage diff = null;

        CanvasFrame canvasFrame = new CanvasFrame("Original stream");
        canvasFrame.setCanvasSize(frame.width(), frame.height());

        CanvasFrame editFrame = new CanvasFrame("Edited stream");
        canvasFrame.setCanvasSize(frame.width(), frame.height());

        CvMemStorage storage = CvMemStorage.create();

        while (canvasFrame.isVisible() && (frame = grabber.grab()) != null) {
            //cvSmooth(frame, frame, CV_GAUSSIAN, 9, 9, 2, 2);
            if (image == null) {
                image = IplImage.create(frame.width(), frame.height(), IPL_DEPTH_8U, 1);
                //cvCvtColor(frame, image, CV_RGB2GRAY);
            } else {
                prevImage = IplImage.create(frame.width(), frame.height(), IPL_DEPTH_8U, 1);
                prevImage = image;
                image = IplImage.create(frame.width(), frame.height(), IPL_DEPTH_8U, 1);
                cvCvtColor(frame, image, CV_RGB2GRAY);
            }

            if (diff == null) {
                diff = IplImage.create(frame.width(), frame.height(), IPL_DEPTH_8U, 1);
            }

            if (prevImage != null) {
                // perform ABS difference
                cvAbsDiff(image, prevImage, diff);
                // do some threshold for wipe away useless details
                cvThreshold(diff, diff, 64, 255, CV_THRESH_BINARY);

                canvasFrame.showImage(frame);
                editFrame.showImage(diff);

            }
        }
        grabber.stop();
        canvasFrame.dispose();
    }
}

输出:

  

sx = 158sy = 37w = 350h = 350op7线程“main”中的异常   java.lang.UnsatisfiedLinkError中:   /tmp/javacpp94368173067/libjniopencv_core.so:libopencv_core.so.2.4:   无法打开共享对象文件:没有这样的文件或目录   java.lang.ClassLoader $ NativeLibrary.load(Native Method)at   java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)at   java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)at   java.lang.ClassLoader.loadLibrary(ClassLoader.java:1843)at   java.lang.Runtime.load0(Runtime.java:795)at   java.lang.System.load(System.java:1061)at   com.googlecode.javacpp.Loader.loadLibrary(Loader.java:566)at at   com.googlecode.javacpp.Loader.load(Loader.java:489)at   com.googlecode.javacpp.Loader.load(Loader.java:431)at   com.googlecode.javacv.cpp.opencv_core。(opencv_core.java:136)     at java.lang.Class.forName0(Native Method)at   java.lang.Class.forName(Class.java:270)at   com.googlecode.javacpp.Loader.load(Loader.java:453)at   com.googlecode.javacv.cpp.opencv_imgproc。(opencv_imgproc.java:97)     at java.lang.Class.forName0(Native Method)at   java.lang.Class.forName(Class.java:270)at   com.googlecode.javacpp.Loader.load(Loader.java:453)at   com.googlecode.javacv.cpp.opencv_highgui。(opencv_highgui.java:85)     在   com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:174)     在demo1.Demo1.main(Demo1.java:187)引起:   java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_core     在java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)at   java.lang.Runtime.loadLibrary0(Runtime.java:849)at   java.lang.System.loadLibrary(System.java:1087)at   com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)at at   com.googlecode.javacpp.Loader.load(Loader.java:481)... 12更多Java   结果:1建立成功(总时间:0秒)

2 个答案:

答案 0 :(得分:1)

在终端中尝试“echo $ PATH”命令,确保计算机上opencv * .dll文件的路径是否存在。

答案 1 :(得分:0)

它的意思是它无法找到本机依赖项。 JavaCV在内部使用JNI调用来使用OpenCV dll。在Windows上,依赖关系在路径上(可能有多种原因,opencv可能在环境变量或某些资源中)。

我建议通过这个浏览linux:https://code.google.com/p/javacv/