我正在尝试在 Visual Studio 2019 中使用 C# 制作一个简单的图像捕获应用程序。
我想使用外部 USB 网络摄像头来捕获图像,但是当我尝试初始化设备时,我意识到我必须将 USB 网络摄像头与笔记本电脑上的内置网络摄像头区分开来。
// Finds all video capture devices
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
foreach (var device in devices)
{
// I want to filter my USB Webcam and set it aside from my built-in laptop webcam
}
在其他一些帖子中,他们使用面板方向来区分它
foreach (var device in devices)
{
switch(device.EnclosureLocation.Panel)
{
case Windows.Devices.Enumeration.Panel.Front:
frontCamera = device; //frontCamera is of type DeviceInformation
isUsingFrontCam = true;
break;
case Windows.Devices.Enumeration.Panel.Back:
rearCamera = device; //rearCamera is of type DeviceInformation
break;
default:
//you can also check for Top, Left, right and Bottom
break;
}
}
但就我而言,我使用的是 USB 网络摄像头,所以我认为没有任何方向。有什么建议么?谢谢!