首页 > 解决方案 > 网络摄像头捕获 - 请求图像时超时

问题描述

我正在使用网络摄像头捕获通过以下代码获取 Java 中的网络摄像头图像:

Webcam webcam = Webcam.getWebcamByName("VF0415 Live! Cam Vid. IM Ultra 1");  // USB webcam
webcam.open();
BufferedImage image = webcam.getImage();
ImageIO.write(image, "JPG", new File("test.jpg"));

不幸的是,我因以下错误而超时:

[main] INFO com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
[atomic-processor-1] INFO com.github.sarxos.webcam.ds.cgt.WebcamOpenTask - Opening webcam VF0415 Live! Cam Vid. IM Ultra 1
[frames-refresher-[1]] ERROR com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice - Timeout when requesting image!
[shutdown-hook-1] INFO com.github.sarxos.webcam.WebcamShutdownHook - Automatic VF0415 Live! Cam Vid. IM Ultra 1 deallocation
[shutdown-hook-1] INFO com.github.sarxos.webcam.Webcam - Disposing webcam VF0415 Live! Cam Vid. IM Ultra 1
[frames-refresher-[1]] ERROR com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice - Timeout when requesting image!

我查看了 GitHub 上的相关问题,并尝试保持 USB 电源打开拦截 OS 信号,但错误消息保持不变,给我一个基本上黑色的图像,如下所示:

本质上是黑色的图像

还有什么我可以尝试解决的吗?

标签: javaimagewebcamimage-recognitionwebcam-capture

解决方案


推荐阅读