2013-08-01 100 views
0

我使用javacv編碼用於運動檢測的代碼在Java中,這是完全的窗口上運行,但在Ubuntu 13.04它顯示了這樣的錯誤,請提出這個方案,我附加代碼也java.lang.UnsatisfiedLinkError中的/ tmp/javacpp94368173067/libopencv_core.so.2.4:無法打開共享對象文件:沒有這樣的文件或目錄

代碼

/* 
* 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 Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/javacpp94368173067/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.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 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) at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:174) at demo1.Demo1.main(Demo1.java:187) Caused by: java.lang.UnsatisfiedLinkError: no opencv_core in java.library.path at 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 com.googlecode.javacpp.Loader.load(Loader.java:481) ... 12 more Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds)

回答

0

它只是表示它無法找到本地依賴項。 JavaCV在內部使用JNI調用來使用OpenCV DLL。在windows上,依賴關係在路徑上(可能有多種原因,opencv可能在環境變量或某些資源中)。

我會建議通過這個打算對於Linux:https://code.google.com/p/javacv/

1

嘗試在終端的「回聲$ PATH」命令,並確保該路徑的OpenCV你的機器上的* .dll文件是有或沒有。

相關問題