2

当我在具有多个 Windows 网络摄像头的计算机上使用 Xuggler 库时,我需要使用此网络摄像头的“名称”来选择设备。我的意思是命令“vfwcap 0”只选择第一个网络摄像头,命令“vfwcap 1”或“vfwcap 2”不允许访问其他网络摄像头。如果我使用:

$ ffmpeg -list_devices true -f dshow -i dummy

我可以看到这个网络摄像头的“名称”列表。例如:“罗技高清网络摄像头 C270”、“罗技网络摄像头 C210”。如果我在 Xuggler 库中使用这个名称,我会收到错误消息。

因此,我只能使用 Xuggler 访问 Windows 机器上的第一个网络摄像头。

我可以从 Xuggler 获取 Windows 中所有设备的列表吗?我可以在 Xuggler 中使用这个名称吗(我只想同时使用多个网络摄像头)?

也许存在替代方式?

4

1 回答 1

2

使用这个简单的 java 程序,您可以获得系统上所有可用网络摄像头的列表。

import com.github.sarxos.webcam.Webcam;

public class CameraTest {
    public static void main(String[] args) {
        List<Webcam> list = Webcam.getWebcams();

        for (int i = 0; i < list.size(); i++) {
                try {
                    Webcam cam = list.get(i);
                    System.out.println("Found this Camera : "+cam.getName());
                    BufferedImage image = cam.getImage();
                } catch (Exception e) {
                    System.out.println("Exception in cam : " + i);
                }
        }
    }
}

样本输出:

Found this Camera : TV CARD WDM VIDEO CAPTURE 0
Found this Camera : ManyCam Video Source 1
Found this Camera : DroidCam 2

您将拥有所有相机的列表,因此您可以随意使用其中的任何一个。

于 2013-03-20T15:12:41.147 回答