Exemplo n.º 1
0
 public void Search()
 {
     //AforgeVideoSourceLite.GetDevices(ref DeviceCache);	//FIX: use this if you have problems with device .. it uses only base directshow calls. No device capabilityList
     PSEyeSource.GetDevices(ref DeviceCache);
     AforgeVideoSource.GetDevices(ref DeviceCache);
     FileVideoSource.GetDevices(ref DeviceCache);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Static func that performs search for devices and adds them to referenced device cache
        /// </summary>
        /// <param name="deviceCache"></param>
        public static void GetDevices(ref Dictionary <string, IVideoSource> deviceCache)
        {
            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (videoDevices != null && videoDevices.Count > 0)
            {
                foreach (FilterInfo device in videoDevices)
                {
                    lock (deviceCache)
                    {
                        if (deviceCache.ContainsKey(device.MonikerString))
                        {
                            continue;
                        }

                        //else .. all other code

                        try
                        {
                            var video = new VideoCaptureDevice(device.MonikerString);

                            var capList = video.VideoCapabilities.Select(cap => new DeviceCapabilityInfo(cap)).ToList();

                            // System.Diagnostics.Debug.WriteLine(device.MonikerString.ToString());
                            var dev = new AforgeVideoSource(device.Name, capList, video);

                            deviceCache.Add(device.MonikerString, dev);
                        }
                        catch (Exception e)
                        {
                            System.Windows.Forms.MessageBox.Show(string.Join(Environment.NewLine, e.Message, "", e.Source, "", e.StackTrace));
                        }
                    }
                }
            }
        }