Have you ever heard of the Open Source Computer Vision Library (OpenCV)? Well if you haven't, you might want to head over to the project's
Wiki page or
Intel's project page. In short, OpenCV is an cross platform open source library (written in C++) that provides a great deal aid for developing computer vision applications. OpenCV can be used for biometrics, security, human-computer interfacing, etc. The brilliant people behind OpenCV have given us the ability to quickly implement such advanced techniques as Face Detection and
Fast Object Tracking.
About a week ago, a friend of mine told me a he was interested in implementing some basic face/feature detection features in a web-based surveillance system (well...a viewer at least). Now, after some research, you can quickly come across some .Net wrappers such as
OpenCVDotNet, but what he needed had to be either Java or 100% C# (so he could convert it to Java...haha) so that the functionality was as (easily) portable as possible. I chose to write a quick proof-of-concept in C# (at least for the face detection piece). So I did my best to quickly port the face detection functionality from OpenCV. OpenCV is great, but there are some knocks against its face detection...the most prominent ones being that it doesn't take lighting into account enough (it won't find faces in some images that other libraries will and it will report false negatives sometimes) and the fact that it may actually violate a patent.
Below you will find what my code as a library project, and a sample project that uses the Yale Face Database. Keep in mind that the code below is just a proof-of-concept and that it can definitely be optimized. I've also skipped doing image histogram equalization which might find more faces in certain images. OpenCV also uses a
k-nearest neighbor algorithm which i didn't really bother to port...I just used Euclidean distance (I'm not sure if that is what OpenCV was already using)...which should work most of the time. In my testing with the Yale Face Database, faces can be detected in ~1.4 seconds on a 300x300 image. That's nowhere near realtime detection, but that's mostly due (I think) to the bounds checking in .NET arrays and lists. Quick profiling show that for a 300x300 image, there are about 52 million array accesses in that ~1.4 seconds which ain't too bad for C#. So here are some scissors....run with 'em.
Face Detection Library
Face Detection Sample Application