我正在尝试如何使用marvin框架激活网络摄像头和捕获视频。我安装了javacv和opencv,但仍然遇到异常。我不知道这是由于opencv和javacv的版本问题还是什么引起的。希望你们能提供帮助。
这里是例外:
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)该本地库必须位于要启动的JVM的类路径上。
有关详细信息,请参见this similar question