我正在尝试研究如何使用 marvin 框架激活网络摄像头并捕获视频。我安装了 javacv 和 opencv 但仍然出现异常。不知道是因为opencv和javacv版本的问题还是什么。 希望大家能帮忙。
这是一个异常(exception):
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
还有这条消息:
SETUP: Setting up device 0
SETUP: HP Webcam
SETUP: Couldn't find preview pin using SmartTee
SETUP: Default Format is set to 640 by 360
SETUP: trying requested format RGB24 @ 640 by 480
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.
'
这是我的代码:
public class SimpleVideoTest extends JFrame implements Runnable{
private MarvinVideoInterface videoAdapter;
private MarvinImage image;
private MarvinImagePanel videoPanel;
public SimpleVideoTest(){
super("Simple Video Test");
// Create the VideoAdapter and connect to the camera
MarvinVideoInterface videoAdapter = new MarvinJavaCVAdapter();
try {
videoAdapter.connect(0);
} catch (MarvinVideoInterfaceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Create VideoPanel
videoPanel = new MarvinImagePanel();
add(videoPanel);
// Start the thread for requesting the video frames
new Thread(this).start();
setSize(800,600);
setVisible(true);
}
public static void main(String[] args) {
SimpleVideoTest t = new SimpleVideoTest();
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void run() {
while(true){
// Request a video frame and set into the VideoPanel
try {
image = videoAdapter.getFrame();
} catch (MarvinVideoInterfaceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
videoPanel.setImage(image);
}
}
最佳答案
你到底是如何启动你的java应用程序的?
openCV 有一个原生库(参见 this doc ,指 libopencv_java*.so/dll) 该 native 库需要位于您要启动的 JVM 的类路径上。
参见this similar question详细了解如何操作
关于java - 线程中出现异常 "main"java.lang.UnsatisfiedLinkError : no jniopencv_core in java. library.path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58257440/