secile / UsbCamera

C# source code for using usb camera and web camera in WinForms/WPF. With only single CSharp source code. No external library required.
MIT License
179 stars 55 forks source link

UsbCamera #3

Closed Onafets51 closed 4 years ago

Onafets51 commented 4 years ago

I am using your work with satisfaction and I would like to know, since some cameras have a serial code, would it be possible to read it?

secile commented 4 years ago

Thank you for your question. As long as I know, there is no common way to get device serial code in DirectShow. Instead of that, it is possible to read DevicePath property.

https://docs.microsoft.com/ja-jp/windows/win32/directshow/selecting-a-capture-device?redirectedfrom=MSDN

DevicePath property is not a human-readable string, but is guaranteed to be unique for each video capture device on the system. You can use this property to distinguish between two or more instances of the same model of device.

UsbCamera.FindDevices() currently returns array of USB camera name. To change returns array of USB camera 'DevicePath', change line 686 as below.

prop.Read("FriendlyName", ref value, 0);

to

prop.Read("DevicePath", ref value, 0);