0

我在 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
4

1 回答 1

1

如果我是正确的,这是在 Webcam Capture API 代码中发现的死锁问题之一。有关详细信息,您可以在Webcam Capture Github 项目页面上查看这些票:#128#30

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

于 2013-11-15T19:32:07.593 回答