Detecting faces
In this recipe, we will examine how our application can be used to recognize human faces. Thanks to the OpenCV library, it is really easy.
Getting ready
We will be using the OpenCV library, so please refer to the Integrating with OpenCV recipe for information on how to set up your project. We will need a sample image to proceed, so save it in your assets
folder as image.png
. Put the Haar cascade classifier file for frontal face recognition inside the assets
directory. The cascade file can be found inside the downloaded OpenCV package or in the online public repository, located at https://github.com/Itseez/opencv/blob/master/data/haarcascades/haarcascade_frontalface_alt.xml.
How to do it…
We will create an application that demonstrates the usage of cascade classifier from OpenCV with Cinder. Perform the following steps to do so:
Include necessary headers:
#include "cinder/gl/Texture.h" #include "cinder/Surface.h" #include "cinder/ImageIo.h"
Add the following members to your main...