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