BOOST THE WORLD: FACE DETECTION

Full Frontal / Partial Faces

LBP | HAAR | HOG


Face detection is not a trivial task, especially if you want to perform it on ARM devices. Before using the following cascades read carefully this page to get the best performance and to know the terms of usage.


The more appealing solution to perform face detection is the real-time face detection scheme proposed by Viola and Jones – basically a cascade of AdaBoost classifiers, which is arguably the most commonly employed detection method. Core of the face detection scheme is the detection model, trained with the OpenCV suite.  There are two applications in OpenCV to train the cascades: opencv_haartraining and opencv_traincascade. The opencv_traincascade suite is a C++ newer version, in accordance to OpenCV 2.x API. The opencv_traincascade suite supports Haar, LBP (Local Binary Patterns) and HOG (Histogram of Oriented Gradients) features. LBP and HOG features are integer, fewer and more discriminant in contrast to Haar features, so both training and detection with LBP and HOG are several times faster then with Haar features. Regarding the HOG, LBP and Haar detection quality, it depends from several issues: the quality of training dataset, training parameters, the semantics of the object to detect. It’s possible to train a LBP-based classifier or an HOG-based classifier that will provide almost or superior quality as Haar-based one.

A cascaded classifier is obtained by chaining a set of monolithic classifiers or stages so to increase the specialization of the classifiers along the cascade. An example is classified as a positive if and only if it is judged so by all stages, while negative examples are discarded according to an early reject strategy. Along training, each stage falsely accepts a fixed ratio f of the non-face patterns in the training sample, while wrongly eliminating only a very small portion 1-d of face patterns; formally:

p (Fi(x) ≥ 0 | Fi-1(x) ≥ 0, y = 1) = d
p (Fi(x) ≥ 0 | Fi-1(x) ≥ 0, y = -1) = f

where Fi(x) is the weighted sum output by the i-th stage classifier, i = 1, … , k, and k is the total number of stages. By applying the conditional rule of probability and recursively exploiting the Markovianity intrinsic to the cascade, the global detection and false acceptance rates of the trained cascade are easily derived as

dg = d^k

fg = f^k

If the training examples are representative of the learning task, one could expect similar detection and false alarm rates also when applying the cascade to test examples (this is one of the biggest error people make when they train a cascade). It is worth spending some words about the assumption according to which the distributions over the training and real world to be the same. On one side it is clear that this hypothesis does not hold strictly: it is sufficient to notice that, due to the nature of tracking (i.e. particle filtering), many hypothesis will be placed in the neighborhood of the face although not perfectly aligned with the pattern. Since the original training sample usually contains only aligned face regions, most of such hypothesis are likely not to be classified as positives by the monolithic classifier. On the other hand, one can expect these examples to pass through a bigger number of stages (weakly inversely proportional to the degree of misplacement) with respect to true negative patterns, resulting in a higher likelihood and hence contributing to the correct estimation of the density distribution.

Moreover, the same issue applies also to hypothesis generated under other circumstances which are not taken into account by the original training, such as out-of-plane rotations. One possible approach is that the out-of-plane rotations are embedded in the training set to extend the class of positives. In this spirit misalignment should be also included; this approach would introduce too much variability for the basic haar_training learning technique which is based on weak features. To perform this harder training we modified the OpenCV approach in positive and negative selection to improve the capabilities of the weak features.

Below it follows our face detection cascades built with OpenCV 2.4.9 / 2.4.11. This frontal face detection model, trained to detect full/partial frontal human faces, is approx. 2x faster than OpenCV and much more reliable and stable for landmarks localization, suitable for real-time apps on ARM devices.

Full frontal (with partial profiles) human face detection cascade, trained with:

  • approx. 17,000 positive samples (randomly sampled)
  • approx 1.1B of negative sub-regions containing outdoor and indoor samples (10%-90%)
  • Training size w=50 h=50 (aspect ratio 1:1)

LBP: (contact us)

  • Features set: 166.464 features
  • Training time: ~3 days
  • TP: ~ 94.51% of positive training set
  • FN: ~ 05.49% of positive training set
  • FP: ~ 6.8e-006% of negative training set

HOG: (contact us)

  • Training time:  ~3 days
  • TP: ~ 93.87% of positive training set
  • FN: ~ 06.13% of positive training set
  • FP: ~ 1e-006% of negative training set

 

 

OpenCV references: documentation and official guide.

34 comments

  1. I am a Masters of Technology(Communications Engineering) student at National Institute Of Technology,Surathkal,India.I am currently working on improving face recognition as part of a research work.Lbp cascades are robust to illumination and as such I want to use lbp cascades for eye detection too.This site is the first to offer the eye lbp cascades.Can I get the xml file for the same for research purposes only.Hoping for a positive reply.

  2. Hi, I am a graduate student from NUS. I am working on face detection using HOG cascades. I have trained a model using traincascade but am not able to detect the same using opencv. Could you help me out as to how I can detect the model using opencv?

    • Hello Aravind,
      thanks for contacting us.

      We will be happy to help you in improving your model for face detection. Can you describe the problem? Which version of OpenCV? Any log of traincascade process (input parameters, sample of the training images, etc.) ?

      • I am using opencv version 3.0 . I am able to detect using the traincascade model in Matlab(so the training process is not a problem). The problem though is that in opencv , I am not able to detect using HOG cascade(which i am able to do using a HAAR model).

        • What does it mean “I am not able to detect”? The program crashes, no detection at all, only some wrong detections here and there? You should be more detailed to allow us to helping you. Did you train the cascade with opencv or with matlab? From opencv 2.4 -> 3.0 there are a lot of modification, bugs are not so rare.

          • The training of the model done using traincascade in opencv.
            Previously I had used the cascade_gpu.detectmultiscale to detect using the model trained. It worked for a HAAR cascade model but is not working for a HOG cascade model. It gives me an error saying ‘OpenCV Error: Unspecified error (The node does not represent a user object (unkn
            own type?)) in unknown function, file ..\..\..\modules\core\src\persistence.cpp,’ . This is the problem i am facing.
            line 4965

  3. The training of the model done using traincascade in opencv.
    Previously I had used the cascade_gpu.detectmultiscale to detect using the model trained. It worked for a HAAR cascade model but is not working for a HOG cascade model. It gives me an error saying ‘OpenCV Error: Unspecified error (The node does not represent a user object (unkn
    own type?)) in unknown function, file ..\..\..\modules\core\src\persistence.cpp,’ . This is the problem i am facing.
    line 4965

    • We are not able to debug your OpenCV code, moreover there are so many versions with so many bugs. In our opinion, you are experiencing -not a bug- but a missing feature not yet implemented. Let’s re-build your opencv solution with debug flags and check which field is missing and you will find why your demo is crashing. Then, try the HOG cascade with a non-GPU demo, it’s the first step to be sure your model is correct and suitable for opencv.

      Regards,
      vision-ary team

      • Thank you for the prompt reply. I would just like to know if you have come across any piece of code to detect HOG cascades in opencv. If so, could you guide me to it. In the mean time , I will look into the aspects you have suggested.

        • Yes we tested some parts of the detection suite, but without GPU detection. From version to version there are differences and bugs, our suggestion is using opencv 2.4.9 without GPU. Keep in touch!

  4. Hello,
    my name is Roberto and I would like to know if it is possible to have the face detection cascade trained with HOG?

    Thank you in advance and keep the good work.

  5. Hello, I am recently doing some researches on face detection.
    I had implement some programs with OpenCV 3.0 but was not satisfied with its speed.
    I am curious about the HOG features you used and the reason you got the speed up.
    Thank you in advance.

    • HOG features are more descriptive than other features, in some cases this skill lead to a smaller number of features and a faster analysis. Finding this trade-off is not trivial, take a look to this paper “Learning Complexity-Aware Cascades for Deep Pedestrian Detection” for a formal discussion about a similar topic: http://arxiv.org/pdf/1507.05348.pdf

      Our cascades are faster because we have modified the training process to force the features to be more discriminative in real environments. According to this strategy the “weight” of the cascade is lower than usual.

  6. GOOD JOB !
    hello,I am han. Is it possible to have the face detection cascade(xml) trained with HOG? (i am working on the 2.4.11) Thank you very much.

    • Hello,

      HOG cascades are not public at the moment, please contact us by contact form to specify the project you want to approach and the name of your company. We will evaluate your request.

      Regards,
      Vision-ary team.

  7. Does it work in real-time scenarios ??
    If it does, can you please send me
    I am still studying and i need it for my project purposes

    • Hello Raffeq,
      of course it works in real time scenarios, this is the main purpose of our effort. We are able to detect objects in real time on very low cost boards and from multiple streams.

      If you need extra Cascades please contact us by contact form.

      Regards,
      Vision-ary team.

  8. Hi , I am a Graduate student at IIT Roorkee. I am working on face recognition. But I have to first detect face. Can u share me with HOG cascade (xml) file for the research work.
    Thanks in advance !!!

    • Hello Shadab,
      for face recognition purposes you can use the cascade that you find on this page or the default one in OpenCV. There’s no reason for using a different cascade, the LBP one is perfect to initialize your face-rec algorithm.

      Regards,
      Vision-ary team

  9. Hi Vision-ary team,

    Could I please receive a copy of the trained full frontal cascade HOG detection file? I’m doing a survey on several different face detection methods, and want to measure the accuracy of the HOG features approach.

    Thanks!
    Tullie

    • Hello Tullie,
      please specify for which university/research center do you work, we need to be sure the cascade will adopted only for academic research.

      Regards,
      Vision-ary team

      • I’m an undergraduate student at the University of Adelaide (in Australia). I can assure you the data will only be used for academic research. Let me know if you require any more information.

        Regards,
        Tullie

      • Hi, just wanted to make sure you’ve seen my comment. Worse comes to worse, i’ll need to train my own HOG model so it would be good to know as soon as possible.

        Regards,
        Tullie

        • Sorry Tullie, at the moment the HOG model is under evaluation by a couple of company interested in our research. No sharing is planned at the moment.

          Regards,
          Vision-ary team

  10. Hello, my name is Pablo, I’m a student of computer science and I want to experiment with unity and face detection, can you please share with me the lbp cascade?

    • Send us an email by the contact form 🙂

      Please highlight to us your goal, if the request is for commercial or an academic project, etc. We will reply to you very soon!

      Regards,
      vision-ary team

      • The project is for academic purposes, I’m working in my final project and want to experiment if I really want to include face detection

        • In this case we suggest to use the opencv facedetect implementation. No reasons to ask for our cascades if the goal is getting in touch with face detection technology.

          • You are welcome.

            If you need help in getting in touch with opencv facedetection please write here 🙂

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *