string savedMonikerString = myFilter.MonikerString;
Filter mySelectedFilter = new Filter(savedMonikerString);
/// <summary> /// Populate the InnerList with a list of filters from a particular category /// </summary> protected void GetFilters(Guid category) { int hr; object comObj = null; ICreateDevEnum enumDev = null; UCOMIEnumMoniker enumMon = null; var mon = new UCOMIMoniker[1]; try { // Get the system device enumerator Type srvType = Type.GetTypeFromCLSID(Uuid.Clsid.SystemDeviceEnum); if (srvType == null) throw new NotImplementedException("System Device Enumerator"); comObj = Activator.CreateInstance(srvType); enumDev = (ICreateDevEnum)comObj; // Create an enumerator to find filters in category hr = enumDev.CreateClassEnumerator(ref category, out enumMon, 0); if (hr != 0) return; //throw new NotSupportedException("No devices of the category"); // Loop through the enumerator int f; do { // Next filter hr = enumMon.Next(1, mon, out f); if ((hr != 0) || (mon[0] == null)) break; // Add the filter var filter = new Filter(mon[0]); InnerList.Add(filter); // Release resources Marshal.ReleaseComObject(mon[0]); mon[0] = null; } while (true); // Sort InnerList.Sort(); } finally { enumDev = null; if (mon[0] != null) Marshal.ReleaseComObject(mon[0]); mon[0] = null; if (enumMon != null) Marshal.ReleaseComObject(enumMon); enumMon = null; if (comObj != null) Marshal.ReleaseComObject(comObj); comObj = null; } }
public void Unload() { if (Capture != null) { Capture.StopPreview(); Capture.Dispose(); } VideoDevice = null; GC.Collect(); }
/// <summary> /// Default constructor of the Capture class. /// </summary> /// <param name="videoDevice">The video device to be the source.</param> /// <exception cref="ArgumentException">If no video device is provided.</exception> public CaptureWebcam(Filter videoDevice) { if (videoDevice == null) throw new ArgumentException("The videoDevice parameter must be set to a valid Filter.\n"); this.VideoDevice = videoDevice; CreateGraph(); }