Skip to Content
Hands-On Robotics Programming with C++
book

Hands-On Robotics Programming with C++

by Dinesh Tavasalkar
March 2019
Intermediate to advanced
312 pages
7h 37m
English
Packt Publishing
Content preview from Hands-On Robotics Programming with C++

Face-detection program

Let's write a program to detect a human face. I have named this program FaceDetection.cpp and you can download it from the Chapter08 folder of this book's GitHub repository.

Since we will be using haarcascade_frontalface_alt2.xml to detect faces, please make sure that the FaceDetection.cpp and haarcascade_frontalface_alt2.xml files are in the same folder.

To program face detection, follow these steps:

  1. In the FaceDetection.cpp program, load the Haar's pre-trained frontal face XML using the CascadeClassifier class, as shown in the following code snippet:
CascadeClassifier faceDetector("haarcascade_frontalface_alt2.xml");
  1. Declare two matrix variables, called videofeed and grayfeed, along with a VideoCapture variable, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Robotics Programming

Learn Robotics Programming

Danny Staple
C++ Reactive Programming

C++ Reactive Programming

Praseed Pai, Peter Abraham

Publisher Resources

ISBN: 9781789139006Supplemental Content