Java 网络摄像头捕获有时才起作用
我在windows中有一个简单的网络摄像头程序,它“偶尔”工作,但大多数时候它在试图找到默认驱动程序时挂起Java 网络摄像头捕获有时才起作用,java,driver,webcam,Java,Driver,Webcam,我在windows中有一个简单的网络摄像头程序,它“偶尔”工作,但大多数时候它在试图找到默认驱动程序时挂起 public class JavaApplication54 { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { Webcam webcam = Webcam.getWebcams().get(0);
public class JavaApplication54 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
Webcam webcam = Webcam.getWebcams().get(0);
webcam.open();
BufferedImage image = webcam.getImage();
ImageIO.write(image, "PNG", new File("test.png"));
image = null;
webcam.close();
}
}
我得到的输出是
13:22:08.910 [main] INFO c.g.sarxos.webcam.WebcamDriverUtils -
Searching driver com.github.sarxos.webcam.ds.openimaj.OpenImajDriver
13:22:08.915 [main] DEBUG c.g.sarxos.webcam.WebcamDriverUtils -
Driver com.github.sarxos.webcam.ds.openimaj.OpenImajDriver not found
13:22:08.915 [main] INFO c.g.sarxos.webcam.WebcamDriverUtils -
Searching driver com.github.sarxos.webcam.ds.civil.LtiCivilDriver
13:22:08.915 [main] DEBUG c.g.sarxos.webcam.WebcamDriverUtils -
Driver com.github.sarxos.webcam.ds.civil.LtiCivilDriver not found
13:22:08.915 [main] INFO c.g.sarxos.webcam.WebcamDriverUtils -
Searching driver com.github.sarxos.webcam.ds.jmf.JmfDriver
13:22:08.916 [main] DEBUG c.g.sarxos.webcam.WebcamDriverUtils -
Driver com.github.sarxos.webcam.ds.jmf.JmfDriver not found
13:22:08.916 [main] INFO com.github.sarxos.webcam.Webcam - Webcam
driver has not been found, default one will be used! 13:22:08.925
[main] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
如果我是正确的,这是在网络摄像头捕获API代码中发现的死锁问题之一。有关详细信息,您可以在以下页面查看这些票证:
我想你的解决方案是使用最新版本,也就是(在我写这个答案的时候)。无论用于开发的IDE(或CLI)如何,它都应该可以工作。我刚刚发现,这似乎只有在Netbeans中运行时才会发生。如果我运行JAR,我将获得100%的成功。因此,我想问题可能在于netbeans包装它运行的程序的方式。任何人都知道如何解决这个问题,因为这将使调试变得更加容易。谢谢