我正在尝试如何使用 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有一个原生库(参见这个文档,参考libopencv_java*.so/dll( 该本机库需要位于要启动的 JVM 的类路径上。
有关如何的详细信息,请参阅此类似问题