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