Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# EMGU EMGUCV
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 20-Nov-10 9:29am
Edited 29-Sep-11 9:01am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is an open source project. You will do better to post your question in that community.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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. Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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:
//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
 
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
  Permalink  
Comments
Dalek Dave at 24-Nov-10 6:20am
   
Great answer.
ManfredRBihy at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I want to detect eyes,mouth and nose.Is it possible in emgu CV??
  Permalink  
Comments
kingUD at 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)

  Print Answers RSS
0 Mathew Soji 274
1 BillWoodruff 270
2 Afzaal Ahmad Zeeshan 244
3 Sergey Alexandrovich Kryukov 240
4 Raul Iloc 160
0 OriginalGriff 6,219
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,103
3 Manas Bhardwaj 4,549
4 Maciej Los 3,845


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 20 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100