0

I've been doing some research and attempted to build a haarcascade for identifying gender.

I read this article, which describes how they did it, which i also tried to do : http://www.ijcce.org/papers/301-E043.pdf

I used a library of 228 male faces and 350 female faces. Using the opencv createclassifier on my positives.txt file which contains a list of the male faces. Using the .vec file create by the classifier I used haartraining with the following command:

opencv_traincascade -data classifier -vec positivies.vec -bg negatives.txt -numStages 20 -minHitRate 0.99 -maxFalseAlarmRate 0.5 -numPos 228 -numNeg 350 -w 640 -h 480 -mode ALL

After running this a few times I do not get a haar classifier.xml output file so I'm unsure whether I am doing everything correctly.

But my question is whether it is possible using male faces as positive samples and female as negative samples to train and use a haarcascade for classifying gender?

user3298970
  • 1
  • 1
  • 8
  • 1
    i don't think, that your idea is feasible. the CascadeClassifier is a binary one. if you train it on male faces, all it can say is male face, or **no** face, e.g. it can't distinguish between a non-face and a female one. – berak Jan 15 '15 at 15:48
  • Would it be feasible to use the HOG classifier to detect if there is a pedestrian and then wether that pedestrian has a male face? If no male face is found hen conclude the pedestrian is female? – user3298970 Jan 15 '15 at 15:55
  • Yes that is absolutely feasible, like detecting an eye inside of a face (like in the face detection opencv tutorial). But you should not use pedestrian detection but face detection and use the gender detection only on the detected face region. But not sure whether your method works ;) – Micka Jan 15 '15 at 17:12
  • Can you post sample training images? Or give details about their size and stuff? – Micka Jan 15 '15 at 17:13
  • Yeah sure I got the images from http://agingmind.utdallas.edu/facedb/view/neutral-faces most are 640 x 480 – user3298970 Jan 15 '15 at 17:18
  • Did you follow this guide? http://docs.opencv.org/doc/user_guide/ug_traincascade.html – Micka Jan 15 '15 at 19:50
  • Yeah with a little help from http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html but I didn't use the mergevec file provided by this example – user3298970 Jan 16 '15 at 11:42

1 Answers1

1

As already said in the comments with one cascade classifier you can only detect a male/female face or no face at all.

But you could just train two classifiers one for female and one for male and then run them both.

For the training I would recommend you to use more training examples.

I used this tutorial. It is for python, but can easily used for every other language, it might help you as well: https://pythonprogramming.net/haar-cascade-object-detection-python-opencv-tutorial/

Silu
  • 176
  • 1
  • 7