Head and people detection in opencv

You can find free LBP Cascade download links specifically designed for people and head detection in OpenCV. It’s trained on my own people and head datasets.
The cascades can be used by using the CascadeClassifier in OpenCV, which allows you to detect objects (such as people and heads) in images or video streams.
Keep in mind that no cascade is perfect, but in some cases, this custom LBP cascade might perform better than the default OpenCV cascades. The differences arise from the shape and feature space used for detection. For instance, the head detector may have more false detections compared to the people detector due to the common features shared by various head shapes.

detect peole head opencv haar cascade

Video example of expected detection results by detectMultiScale


Head cascade and people cascade download link

Head and people detection tutorial code

Update from 2024  opencv installation 
  • I would recommend using the VCPKG installation described on my blog here for the CMake project. 
  • For the Visual Studio project here.
You can simply prepare the project inside the Visual Studio 2015 by Nuget Packages. This approach is easy for beginners and better than standard installation with all the environmental variables problems. Just follow the installation steps here

LBP detectMultiScale cascade Opencv code

This code is based on my previous tutorial with more details Fast people detection.

// 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;
 img.copyTo(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.0440 | 1Size(3080), Size(80,200));
 detectorHead.detectMultiScale(img, head, 1.140 | 1Size(4040), Size(100100));
 if (human.size() > 0) {
  for (int gg = 0; gg < human.size(); gg++) {
    rectangle(original, human[gg].tl(), human[gg].br(), Scalar(00255), 280);
  }
}
 if (head.size() > 0) {
  for (int gg = 0; gg < head.size(); gg++) {
    rectangle(original, head[gg].tl(), head[gg].br(), Scalar(00255), 280);
  }
 }

Next Post Previous Post
13 Comments
  • Unknown
    Unknown February 27, 2017 at 1:02 PM

    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

    • Vl
      Vl March 2, 2017 at 10:30 AM

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

  • Unknown
    Unknown May 17, 2017 at 12:28 AM

    what a nice blog it is!
    Can i share the video file??
    yunjung.erica@gmail.com

  • Unknown
    Unknown June 2, 2017 at 7:51 AM

    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.

    • Unknown
      Unknown March 7, 2019 at 7:41 PM

      Mam can you please provide me the head cascade, i urgently needed, please.Thanks in advance.

  • Unknown
    Unknown August 13, 2017 at 10:22 PM

    شرکت هوشمند افزار آسیا یکی از قدرتمند ترین شرکت های حوزه سیستم های امنیتی و نظارت تصویری و دوربین های مداربسته
    نماینده فروش دوربین های مداربسته هایک ویژن در کرج و تهران

    نصب دوربین مداربسته
    نماینده فروش دوربین های مداربسته هایک ویژن در کرج و تهران
    نماینده فروش دوربین های مداربسته هایک ویژن در کرج و تهران

    مجله تخصصی دوربین مداربسته و سیستم های حفاظتی و امنیتی
    02634216001-02634216002

  • Unknown
    Unknown December 25, 2017 at 12:26 AM

    Thanks.
    holiday palace
    ทางเข้า sbobet

  • Anonymous
    Anonymous January 7, 2018 at 12:05 AM

    Thank you for sharing your knowledge.

    maxbet

    แทงบอล maxbet

    แทงบอล maxbet

  • Linktekc Systems Group
    Linktekc Systems Group March 3, 2018 at 9:18 AM

    Enthusiastic words written in this blog helped me to enhance my skills as well as helped me to know how I can help myself on my own. I am really glad to come at this platform. freelance website development

  • Unknown
    Unknown August 1, 2018 at 6:02 AM

    Do you have implementation in Python? of the same LBP cascade?

  • Anonymous
    Anonymous August 8, 2018 at 4:53 AM

    I need some suggestions on training data more precisely. can you guide me to train my own cascade in a efficient way.
    It would be really helpful for me.

  • basha
    basha March 23, 2019 at 4:48 AM

    Excellent blog I visit this blog it's really awesome. The important thing is that in this blog content written clearly and understandable. The content of information is very informative.
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training
    Oracle Fusion Financials Online Training
    Big Data and Hadoop Training In Hyderabad
    oracle fusion financials classroom training
    Workday HCM Online Training
    Oracle Fusion HCM Classroom Training
    Workday HCM Online Training

  • PoL
    PoL July 9, 2019 at 2:29 PM

    You have a question Where to Find Software Developers? Youteam is a massive professional networking platform with over 590 million registered members, and over 250 million active users in over 200 countries. As you can imagine, it’s become quite the recruiting platform for employers looking for connected professionals.

Add Comment
comment url