2012-12-05 56 views
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 
+0

我刚刚发现,这似乎只发生在我运行Netbeans时。如果我运行JAR,我会获得100%的成功。所以我想这个问题可能与netbeans包装它运行的程序的方式有关。任何人都知道如何解决这个问题,因为这会使调试变得更容易。谢谢 – user845854

回答

1

如果我是正确的,这是在摄像头捕获API代码中发现了僵局问题之一。有关详细信息,您可以检查Webcam Capture Github project页面上可用这些票:#128#30

我想办法解决你的将是使用最新的版本,这是(对的时候,我正在写这个答案)0.3.10-RC6。无论IDE(或CLI)用于开发,它都应该工作。