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++

Eye detection using haarcascade_eye

To test the haarcascade_eye output, observe the following steps:

  1. Load this classifier inside our program:
CascadeClassifier eyeDetector("haarcascade_eye.xml");
  1. To detect the eyes, we need to find the face region (region of interest) in the image (video feed). Inside the face-detection for loop, we will create a Mat variable called faceroi. videofeed(face[f]), which will find faces in videofeed and store them inside the faceroi variable:

Mat faceroi = videofeed(face[f]);
  1. Create a vector of the Rect type, called eyes, and then use the detectMultiScale function to detect the eye region:
vector<Rect> eyes;eyeDetector.detectMultiScale(faceroi, eyes, 1.3, 5, 0 |CASCADE_SCALE_IMAGE,Size(30, 30));

In the ...

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