I am trying to make a simple image capture app using C# in Visual Studio 2019.
I want to use an external USB webcam to capture an image, but when I try to initialize the device, I realized I have to distinguish the USB webcam from my built-in webcam on my laptop.
// 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
}
In some other posts, they distinguish it using panel orientation
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;
}
}
But in my case, I am using USB Webcam so I don't think there is any orientation. Any suggestions? Thank you!
As one of solutions, you can use device ID like below.