网络摄像头捕获有时只能工作

时间:2012-12-05 13:29:42

标签: 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);

    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

1 个答案:

答案 0 :(得分:1)

如果我更正,这是Webcam Capture API代码中发现的死锁问题之一。有关详情,您可以在Webcam Capture Github project页面查看这些门票:#128#30

我认为您的解决方案是使用最新版本,这是(我写这个答案的时候)0.3.10-RC6。无论用于开发的IDE(或CLI)如何,它都应该有效。