0
在这里,我写了一些代码来使用java从USBcam捕捉图像。com.github.sarxos.webcam.WebcamException:无法执行任务
下面是代码:
Webcam webcam = Webcam.getDefault();
webcam.open();
try {
ImageIO.write(webcam.getImage(), "PNG", new File("d:/hello-world1.png"));
System.out.println(Thread.currentThread().getName());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
而且我已经添加了什么都需要,但 运行应用程序时,图像不饶人, 异常升高3罐。
以下是例外:
Exception in thread "main" com.github.sarxos.webcam.WebcamException: Cannot execute task
at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.process(WebcamProcessor.java:57)
at com.github.sarxos.webcam.WebcamProcessor.process(WebcamProcessor.java:120)
at com.github.sarxos.webcam.WebcamTask.process(WebcamTask.java:35)
at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.open(WebcamOpenTask.java:20)
at com.github.sarxos.webcam.Webcam.open(Webcam.java:187)
at com.github.sarxos.webcam.Webcam.open(Webcam.java:147)
at ImageCapture.main(ImageCapture.java:16)
Caused by: com.github.sarxos.webcam.WebcamException: Cannot start native grabber!
at com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice.open(WebcamDefaultDevice.java:220)
at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.handle(WebcamOpenTask.java:38)
at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.run(WebcamProcessor.java:66)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
请建议我在哪里,我把错误的想法。
对不起@SSpoke我得到相同的异常 – user2996174
尝试注释掉'webcam.setViewSize(新尺寸(1024,768));' – SSpoke
好你的问题是'无法启动本地采集'的https:// github上! com/sarxos/webcam-capture/blob/master/webcam -capture/src/main/java/com/github/sarxos/webcam/ds/buildin/WebcamDefaultDevice.java尝试使'setViewSize'变小帮助看看这里创建新的问题,https://github.com/sarxos/webcam-capture/issues – SSpoke