Camera selection bug in WebCam service
There's a bug in UpdateDeviceInternal that will affect systems with one or more camera of the same brand (highlighted below):
foreach (object obj in new vision.CameraCollection())
{
using (vision.Camera camera = obj as vision.Camera)
{
if ((!string.IsNullOrEmpty(selected.FriendlyName) && camera.Name == selected.FriendlyName) ||
(!string.IsNullOrEmpty(selected.DevicePath) && camera.Path == selected.DevicePath))
{
selected.FriendlyName = camera.Name;
selected.DevicePath = selected.DevicePath;
//selected.FrameGrabber = vision.FrameGrabber.FromCamera(camera);
selected.FrameGrabber = Braintech.FrameGrabber.FromCamera(camera);
selected.SupportedFormats = ConvertFormats(selected.FrameGrabber.Formats);
selected.FrameGrabber.CaptureFrame += OnCaptureFrame;
selected.FrameGrabber.StartCapture();
selected.Format = new Format(selected.FrameGrabber.Format);
updated = true;
break;
}
}
}
Supposing you have two cameras with the same FriendlyName on your system (eg. Logitech QuickCam Pro etc), then due to the OR in the if statement, you'll only be able to select the first such camera, regardless of what you put in selected.DeviceName. For the reason described below, this bug only appears you use an initial state partner (not when you configure via the web interface).
Unlike an initial state partner, which stores both the device path and the friendly name, the HTTP Post handler leaves FriendlyName null, so the correct device path can be configured via the web. That complicates the fix- if you change the || to &&, you need to properly set the FriendlyName in HTTPPostHandler (which is non-trivial because the POST event doesn't receive the friendly name... :-( Maybe the best solution is to ignore the friendly name altogether?

