2016-05-06 23 views
1

Ich bin mit opencv 3.1 und nach dem gesamten Konfiguration für javacv Einstellung erhalte ich folgende FehlerKeine jniopencv_highgui in java.library.path

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_highgui in java.library.path 
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738) 
at java.lang.Runtime.loadLibrary0(Runtime.java:823) 
at java.lang.System.loadLibrary(System.java:1028) 
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_highgui.<clinit>(opencv_highgui.java:79) 
at demo.main(demo.java:10) 
Caused by: java.lang.UnsatisfiedLinkError: C:\Users\pankajs\AppData\Local\Temp\javacpp16045999146511\jniopencv_highgui.dll: Can't find dependent libraries 
at java.lang.ClassLoader$NativeLibrary.load(Native Method) 
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807) 
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703) 
at java.lang.Runtime.load0(Runtime.java:770) 
at java.lang.System.load(System.java:1003) 
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:700) 
... 4 more 

Ich denke, die wegen javacv Version. Ich benutze 0.7 Version. Ich weiß nicht, welche Version mit opencv 3.1.0 tatsächlich verwendet wird und wo sie gefunden wird.

import static com.googlecode.javacv.cpp.opencv_core.*; 
import static com.googlecode.javacv.cpp.opencv_highgui.*; 
import com.googlecode.javacv.CanvasFrame; 
public class demo { 
    public static void main(String[] args) { 
    //Load image img1 as IplImage 
    final IplImage image = cvLoadImage("img1.png"); 
    //create canvas frame named 'Demo' 
    final CanvasFrame canvas = new CanvasFrame("Demo"); 
    //Show image in canvas frame 
    canvas.showImage(image); 
    //This will close canvas frame on exit 
    canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); 
    } 
} 

Antwort

1

Obiges Beispiel für mich gearbeitet 0.9 mit javacv

Hier ist der kleine modifizierte Code:

import java.awt.image.BufferedImage; 
import java.io.File; 
import java.io.IOException; 
import javax.imageio.ImageIO; 
import org.bytedeco.javacpp.opencv_core.IplImage; 
import org.bytedeco.javacv.CanvasFrame; 

public class Demo { 
public static void main(String[] args) throws IOException {   
//Load image img1 as IplImage 
    BufferedImage img = ImageIO.read(new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\beach.jpg")); 
    final IplImage image = IplImage.createFrom(img); 

    //create canvas frame named 'Demo' 
    final CanvasFrame canvas = new CanvasFrame("Demo"); 

    //Show image in canvas frame 
    canvas.showImage(image); 

    //This will close canvas frame on exit 
    canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);   
}  
}