aforge.video.directshow. "GetDevicesOfCat" not working

30 Views Asked by At

Using GetDevicesOfCat in dot net code to enumerate the web cameras.

I enumerated the video devices connected to the computer and when I find the one I want i open the one I want with opencvsharp videocapture call.

var devices = new List<DsDevice>(DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice));
for (int x = 0; x < devices.Count; x++)
{
   
    if (devices[x].Name.Contains(camera_name))
    {
       
        device_index = x;
    }

    capture = new videocapture (device index);
}

but it is opening the wrong camera.

This has worked in the past when compiling under x86 but now i am working on a project that needs x64 build. and same code that works in x86 does not work here

It appears the order of the returned camera list is not correct this is a c# win form application running dotnet 8.0

1

There are 1 best solutions below

0
Roman Ryltsov On

32-bit and 64-bit device enumerations do not have to match. So it will be not reliable to use index from one in the other.