Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C++ / CLI » General » Downloads
 
Add your own
alternative version

Intelligent Screen Saver

, 15 Aug 2007 CPOL
A utility to control screen saver on your computer using computer vision (human face detection), rather than idle timer.
intelligentsaver.zip
intelligentsaver2.zip
IntelligentSaver.suo
DxCam
dshow
Core
DxCam.csproj.user
DxCam.suo
Gui
VideoSource
FaceDetection
App.ico
FaceDetection.GUI.csproj.user
FaceDetection.suo
FaceDetectionWrapper
app.ico
release.zip
Release
cv099.dll
cxcore099.dll
DxCam.dll
FaceDetection.exe
FaceDetection.Wrapper.dll
libguide40.dll
Tiger.Video.VFW.dll
requiredbinaries.zip
References
Tiger.Video.VFW.dll
Cascades
OpenCV
cv099.dll
cxcore099.dll
libguide40.dll
vs2005.zip
VS2005
DxCam
dshow
Core
DxCam.csproj.user
DxCam.suo
Gui
VideoSource
FaceDetection
App.ico
FaceDetection.GUI.csproj.user
FaceDetection.suo
FaceDetectionWrapper
app.ico
Bayesian_ML_DLL.vcproj.Z.Zeeshan.user
IntelligentSaver.suo
namespace dshow
{
	using System;
	using System.Collections;
	using System.Runtime.InteropServices;
	using dshow.Core;

	/// <summary>
	/// Summary description for FilterCollection.
	/// </summary>
	internal class FilterCollection : CollectionBase
	{
		internal FilterCollection(Guid category)
		{
			CollectFilters(category);
		}

		// collect filters of specified category
		private void CollectFilters(Guid category)
		{
			object				comObj = null;
			ICreateDevEnum		enumDev = null;
			UCOMIEnumMoniker	enumMon = null;
			UCOMIMoniker[]		devMon = new UCOMIMoniker[1];
			int					hr;

			try
			{
				// Get the system device enumerator
				Type srvType = Type.GetTypeFromCLSID(Clsid.SystemDeviceEnum);
				if (srvType == null)
					throw new ApplicationException("Failed creating device enumerator");

				// create device enumerator
				comObj = Activator.CreateInstance(srvType);
				enumDev = (ICreateDevEnum) comObj;

				// Create an enumerator to find filters of specified category
				hr = enumDev.CreateClassEnumerator(ref category, out enumMon, 0);
				if (hr != 0)
					throw new ApplicationException("No devices of the category");

				// Collect all filters
				int n;
				while (true)
				{
					// Get next filter
					hr = enumMon.Next(1, devMon, out n);
					if ((hr != 0) || (devMon[0] == null))
						break;

					// Add the filter
					Filter filter = new Filter(devMon[0]);
					InnerList.Add(filter);

					// Release COM object
					Marshal.ReleaseComObject(devMon[0]);
					devMon[0] = null;
				}

				// Sort the collection
				InnerList.Sort();
			}

			finally
			{
				// release all COM objects
				enumDev = null;
				if (comObj != null)
				{
					Marshal.ReleaseComObject(comObj);
					comObj = null;
				}
				if (enumMon != null)
				{
					Marshal.ReleaseComObject(enumMon);
					enumMon = null;
				}
				if (devMon[0] != null)
				{
					Marshal.ReleaseComObject(devMon[0]);
					devMon[0] = null;
				}
			}
		}

		// Get a filter at the specified index
		internal Filter this[int index]
		{
			get
			{
				return ((Filter) InnerList[index]);
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Zeeshan Ejaz Bhatti
Web Developer
Pakistan Pakistan
BCSE - Software Engineering (2000 - 2004)
Foundation University Institute of Management and Computer Sciences.
Pakistan.
 
MS - Computer Sciences (2004 - 2005)
Lahore Univeristy of Management Sciences
Pakistan.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 15 Aug 2007
Article Copyright 2007 by Zeeshan Ejaz Bhatti
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid