我正在尝试使用 opencv 使用 netbeans 在 Java 中加载视频文件。有人知道这样做的方法吗?我在网上搜索找不到解决方案。
最佳答案
您需要将 C:\opencv\build\x86\vc11\bin 添加到 Path 变量... 并写:
private void myMethod(...) {
Mat frame = new Mat();
VideoCapture camera = new VideoCapture("C:/MyName/MyPc/Desktop/TheLordOfTheRings.mp4");
JFrame jframe = new JFrame("MyTitle");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel vidpanel = new JLabel();
jframe.setContentPane(vidpanel);
jframe.setVisible(true);
while (true) {
if (camera.read(frame)) {
ImageIcon image = new ImageIcon(Mat2bufferedImage(frame));
vidpanel.setIcon(image);
vidpanel.repaint();
}
}
}
关于java - 如何在java中使用Opencv加载视频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35076578/