gpt4 book ai didi

Java编程,opencv未满足链接错误

转载 作者:行者123 更新时间:2023-11-30 02:12:57 25 4
gpt4 key购买 nike

OpenCV 库在捕获视频流时出现不令人满意的链接错误。

opencv 3.2.0 库应该在哪里? opencv类包的正确路径是什么?

代码在哪里生成此错误:

package opencv;

import org.opencv.core.*;

import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.videoio.VideoCapture;
public class VideoCap
{

public static void main (String args[]){

System.loadLibrary(Core.NATIVE_LIBRARY_NAME); // error

VideoCapture camera = new VideoCapture(0);

if(!camera.isOpened()){
System.out.println("Error");
}
else {
Mat frame = new Mat();
while(true){
if (camera.read(frame)){
System.out.println("Frame Obtained");
System.out.println("Captured Frame Width " +
frame.width() + " Height " + frame.height());
Imgcodecs.imwrite("camera.jpg", frame);
System.out.println("OK");
break;
}
}
}
camera.release();
}
}

异常(exception)情况是:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
no opencv_java320 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at opencv.VideoCap.main(VideoCap.java:9)

最佳答案

尝试克隆以下存储库:

https://github.com/hellonico/opencv4_java_tutorial.git

在 java 文件夹中添加您的类,而不是使用 System.loadLibrary ...使用:

NativeLoader.loadLibrary(Core.NATIVE_LIBRARY_NAME);

这将加载正确编译的 OpenCV 版本以在 JVM 中运行。

关于Java编程,opencv未满足链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49581404/

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