Hi,
There are many many ways of detecting facial features in image analysis terms and EMGU. A good starting point for you would be the FaceDetection example in the Emgu.CV.Example folder of the installation. This utilise a method of feature detection called Haar classification. There are different Haar classifiers supplied with EMGU located in ...\opencv\data\haarcascades folder. under your chosen installation directory.
All classifiers are XML Documents(.xml) containing complex cascades that examine the image looking for patterns that correspond to trained features such as face eyes nose and mouth. The two you will be interested in are:
haarcascade_eye.xml
haarcascade_mcs_mouth.xml
We read in the Haar classifiers:
HaarCascade face = new HaarCascade("haarcascade_frontalface_alt_tree.xml");
HaarCascade mouth = new HaarCascade("haarcascade_mcs_mouth.xml");
HaarCascade eye = new HaarCascade("haarcascade_eye.xml");
We include the face as this limits the are we are looking for eyes and mouth. Make sure you when you add the Haar classifier to your project you change the "Copy to Output Directory" property to
Copy if Newer else it won't be able to be located.
We can the alter the Face Detection code to show us mouths by adding
MCvAvgComp[][] mouthsDetected = gray.DetectHaarCascade(
mouth,
1.1,
10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(20, 20));
gray.ROI = Rectangle.Empty;
foreach (MCvAvgComp e in mouthsDetected[0])
{
Rectangle mouthRect = e.rect;
mouthRect.Offset(f.rect.X, f.rect.Y);
image.Draw(mouthRect, new Bgr(Color.Green), 2);
}
When you run this on lena.jpg you won't detect the mouth correctly you must now change the DetectHaarCascade attributes you will have toplay with each value to detect the mouth properly however I suggest that you now work on your own acquired images to perfect these settings.
DetectHaarCascade(HaarCascade haarObj, double scaleFactor, int minNeighbors, HAAR_DETECTION_TYPE flag, Size minSize);
On a small note I would only change one attributes at a time so you observe the changes.
I would suggest not looking into creating your own Haar classifiers as this is fairly complex if you don't understand EMGU C# and C++ and takes a long time computationally to compute.
An easy alternative method you may wish to employ is template matching which is useful mainly if your dealing only with portraits or faces from a constant angle. This could also by employed to further analyse the results from the Haar Classifiers looking for Iris's of the eye for example.
I hope this starts to get you on your way.
Cheers
Chris