gpt4 book ai didi

java - java.library.path 中没有 jniopencv_highgui

转载 作者:太空宇宙 更新时间:2023-11-03 22:51:39 26 4
gpt4 key购买 nike

我正在使用 opencv 3.1,在为 javacv 设置所有配置后我得到以下错误

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

我认为是因为 javacv 版本。我正在使用 0.7 版本。我不知道 opencv 3.1.0 实际使用哪个版本以及它会在哪里找到。

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

最佳答案

上面的例子对我有用,使用 javacv 0.9

这是修改后的代码:

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

关于java - java.library.path 中没有 jniopencv_highgui,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37067892/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com