Face detection with Emgu CV

I was wondering how facebook tag functionality work,  how it would be smart enough to draw a rectangle to a person face and tag it. Well i’m not trying to do something that complex yet, i just want to draw a rectange around a person’s face.

So i head to Emgu CV.

Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library. Allowing OpenCV functions to be called from .NET compatible languages such as C#, VB, VC++, IronPython etc. The wrapper can be compiled in Mono and run on Windows, Linux, Mac OS X, iPhone, iPad and Android devices.


And the result ?


The actual algorithm to do this i believe is pretty complex, thankfully i don’t need to mind all that complicated stuff and just use the functionality from Emgu CV.

Here are the steps that i used to build this simple app

  • Head to sourceforge and download the installer, i’m using version 2.4.2. Needless to say you need to install it.
  • Create an empty ASP.NET website project
  • Change the configuration properties to build in x86
  • Reference Emgu.CV.dll, Emgu.CV.UI.dll, and Emgu.Util.dll
  • Right click project and add existing items, go to Emgu installation directory and under x86 add all the dlls
  • Add an aspx page to handle the file upload and displaying the image
  • Add an ashx handler to do the face detection.
  • Add the haarcascade_frontalface_default.xml file to the solution.

Too simple, i know, i’m too lazy to put pretty picture on the steps. I think seeing the code is much better idea anyway.

Here you go https://github.com/reyrahadian/facedetection.emgucv

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.