Head and people detection in opencv


My favourite

  • Opencv tutorial people detection
  • Head people cascade download
  • Opencv tutorial optical flow
  • Opencv Video stabilization
  • Opencv car dataset download
  • Opencv tutorial Transparent mask
  • Opencv videowriter
  • Opencv FFMPEG
  • Opencv Canny edge and hough lines
  • LBP cascade for detect head and people in opencv 

    LBP cascade free to download to use in opencv to detect people and heads. Code example and cascade description. All you need to write your own people head detector from the youtube video.
    Cascade is trained on my own people and head datasets. There are no perfect but in some cases are better then default opencv cascades. They are just different.. For example you can count that the head detector have much more false detection than the people detector.. The shape and feature space is much more common and close to others shapes than the whole people detector.

    detect peole head opencv haar cascade

    Issues with opencv detectMultiScale head and people detector

    Please let me know if cascades worked as expected.. In code example there is ground threshold settings and reccomentation. 

    LBP cascade head detection properties

    Sure you can find inside file.

    This is just basic 16 stage lbp cascade head detector develop by 
    V.K. from https://funvision.blogspot.com
    <?xml version="1.0"?>

    New LBP cascade people detection properties

    This is just basic 10 stage lbp cascade head detector develop by 
    V.K. from https://funvision.blogspot.com
    <?xml version="1.0"?>

    Opencv cascade for car detection conditions of use

    Also, Do not worry about the condition of use. Use only on your own risk. That's it. The dataset to train this cascade is only mine. I also colect positive and negative data. I just want to say, that there is also no conditions based on the datasets. There is no others conditions of use. Maybe check the Opencv traincascade utility. Thanks. Yes share and cite. Just small minimal condition like send me a million dolars. Its up to you.

    Head cascade and people cascade download link.

    Head detection download link

    People detection download link

    Head and people detection tutorial code

    You can simple prepare the project inside the Visual Studio 2015 by Nuget Packages. This approach is easy for beginers and better than standard installation with all the environmental variables problems. Just follow the installation steps inside here

    This code is based on my previous tutorial Fast people detection.
    Inside the video capture loop just modify the part like this. Include cascade inside your project and play with different settings.. This is not ideal one..
    // Name of the downloaded my cascades.. 
     string cascadeHead = "cascadeH5.xml";
     string cascadeName = "cascadG.xml";
    // Load the cascade
     CascadeClassifier detectorBody;
     bool loaded1 = detectorBody.load(cascadeName);
     CascadeClassifier detectorHead;
     bool loaded2 = detectorHead.load(cascadeHead);
    // save original make img gray
    // draw rectangle back to the original colored sample
     Mat original;
    // Prepare vector for results 
    vector<Rect> human;
    vector<Rect> head;
    // Prepare gray image
     cvtColor(img, img, CV_BGR2GRAY);
    // equalize Histogram  
            equalizeHist(img, img);
    // detect body and head in the img 
    // Set the proper min and max size for your case
     detectorBody.detectMultiScale(img, human, 1.04, 4, 0 | 1, Size(30, 80), Size(80,200));
     detectorHead.detectMultiScale(img, head, 1.1, 4, 0 | 1, Size(40, 40), Size(100, 100));
     if (human.size() > 0) {
      for (int gg = 0; gg < human.size(); gg++) {
       rectangle(original, human[gg].tl(), human[gg].br(), Scalar(0, 0, 255), 2, 8, 0);
     if (head.size() > 0) {
      for (int gg = 0; gg < head.size(); gg++) {
       rectangle(original, head[gg].tl(), head[gg].br(), Scalar(0, 0, 255), 2, 8, 0);


    1. I want code for Real time Face Recognition System using LBP Algorithm code for opencv 3.1 (C++) in Linux.
      Contact Details:-

      Email:- perrykakkar.1993@gmail.com
      Ph. No:- +91-8930228000

      1. Code is same cascade is different.. There is lots of cascade detect faces. I do not spent time to doing training of that detector..

    2. what a nice blog it is!
      Can i share the video file??

    3. Hi. I'm using the head cascade in my project.
      And my question is if the parameters are the same with the face cascade. All this implemented from python. Also, what would be the correct syntax to call the cascade.
      Thanks for your help.