Wednesday, March 2, 2011

c# Face Detection/Face Recognition Library

Although there is a OpenCVDotNet to wrapper OpenCV with C# language, it seems very difficult for common users to implement Simple Face Detection/Face Recognition as a simple way.Now you don't need to worry about it, because there is a developer has built a pure C# Face Detection Library.


Below you will find what his code as a library project, and a sample project that uses the Yale Face Database.

Face Detection Library  - A C# Library to wrapper basic face detection algorithm.
Face Detection Sample Application - A C# Project to built a simple example to show face detection function and performance issue.

OpenCV 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.

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.

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.

No comments:

Post a Comment