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
A utility to control screen saver on your computer using computer vision (human face detection), rather than idle timer.
intelligentsaver.zip
intelligentsaver2.zip
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.Runtime.InteropServices;
	using dshow.Core;

	/// <summary>
	/// Summary description for Filter.
	/// </summary>
	internal class Filter : IComparable
	{
		// Device name
		internal readonly string Name;

		// Moniker string
		internal readonly string MonikerString;

		// Create new filter from moneker`s string
		internal Filter(string monikerString)
		{
			MonikerString = monikerString;
			Name = GetName(monikerString);
		}

		// Create new filter from it's Moniker
		internal Filter(UCOMIMoniker moniker)
		{
			MonikerString = GetMonikerString(moniker);
			Name = GetName(moniker);
		}


		// Get moniker string of the moniker
		private string GetMonikerString(UCOMIMoniker moniker)
		{
			string str;
			moniker.GetDisplayName(null, null, out str);
			return str;
		}

		// Get filter name represented by the moniker
		private string GetName(UCOMIMoniker moniker)
		{
			Object			bagObj = null;
			IPropertyBag	bag = null;

			try
			{
				Guid bagId = typeof(IPropertyBag).GUID;
				// get property bag of the moniker
				moniker.BindToStorage(null, null, ref bagId, out bagObj);
				bag = (IPropertyBag) bagObj;

				// read FriendlyName
				object val = "";
				int hr = bag.Read("FriendlyName", ref val, IntPtr.Zero);
				if (hr != 0)
					Marshal.ThrowExceptionForHR(hr);

				// get it as string
				string ret = val as string;
				if ((ret == null) || (ret.Length < 1))
					throw new ApplicationException();

				return ret;
			}	
			catch (Exception)
			{
				return "";
			}
			finally
			{
				// release all COM objects
				bag = null;
				if (bagObj != null)
				{
					Marshal.ReleaseComObject(bagObj);
					bagObj = null;
				}
			}
		}

		// Get filter name represented by the moniker string
		private string GetName(string monikerString)
		{
			UCOMIBindCtx bindCtx = null;
			UCOMIMoniker moniker = null;
			String name = "";
			int n = 0;

			// create bind context
			if (Win32.CreateBindCtx(0, out bindCtx) == 0)
			{
				// convert moniker`s string to a moniker
				if (Win32.MkParseDisplayName(bindCtx, monikerString, ref n, out moniker) == 0)
				{
					// get device name
					name = GetName(moniker);

					Marshal.ReleaseComObject(moniker);
					moniker = null;
				}
				Marshal.ReleaseComObject(bindCtx);
				bindCtx = null;
			}
			return name;
		}

		// Compares objects of the type
		public int CompareTo(object obj)
		{
			if (obj == null)
				return 1;

			Filter f = (Filter) obj;
			return (this.Name.CompareTo(f.Name));
		}
	}
}

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)

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 | Mobile
Web02 | 2.8.140721.1 | Last Updated 15 Aug 2007
Article Copyright 2007 by Zeeshan Ejaz Bhatti
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid