Click here to Skip to main content
15,889,865 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I have extracted faces from the running video using emgu cv.
Now I want to extract eyes and mouth from those detected faces and then do feature extraction from detected feature points of eyes and mouth.

can anyone help me for this feature extraction phase? How to detect eyes in emgu cv in C#?
Posted
Updated 29-Sep-11 8:01am
v3

This is an open source project. You will do better to post your question in that community.
 
Share this answer
 
Thanks for your solution
It was really helpfull.

I would like to ask one more question, in the detect haar cascade function the second and third argument that is:double scaleFactor, int minNeighbors.
Iam not actually getting what does they signify and what are their possible values.How to experiment with it. :)
 
Share this answer
 
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:
C#
//Read the HaarCascade objects
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

C#
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.

C#
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
 
Share this answer
 
Comments
Dalek Dave 24-Nov-10 6:20am    
Great answer.
Manfred Rudolf Bihy 24-Nov-10 6:46am    
D'accord! Very good!
(Modified: Oh no voted 1 accidentally, can't undo that. I'm sorry. Ok I made up for my wrong doing and gave your answer to another quesiont regarding this topic a 5)
kingUD 21-Jul-12 11:48am    
nice solution
thanx for help to understand detect object using emgu cv
but i want detect door object . Is it possible in emgu cv ????
pls any solution related to door detect pls send it to dusha4sliit@gmail.com
pls help me

thanx
dushyantha
I want to detect eyes,mouth and nose.Is it possible in emgu CV??
 
Share this answer
 
Comments
kingUD 21-Jul-12 12:07pm    
yes it possible
u want only change cascade path only

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900