Skip to content

Instantly share code, notes, and snippets.

@treyhuffine
Created March 5, 2019 02:03
Show Gist options
  • Save treyhuffine/5b0e4f744fd20aa92dcba502b974012b to your computer and use it in GitHub Desktop.
Save treyhuffine/5b0e4f744fd20aa92dcba502b974012b to your computer and use it in GitHub Desktop.
const string cascade_name = "$OPENCV_ROOT/data/haarcascades/haarcascade_frontalface_default.xml";
CascadeClassifier face_cascade;
if (not face_cascade.load(cascade_name)) {
cerr << "Cannot load cascade classifier from file: " << cascade_name << endl;
return -1;
}
// ... obtain an image in img
vector<Rect> faces;
faceDetector(img, faces, face_cascade);
// Check if any faces were detected or not
if (faces.size() == 0) {
cerr << "Cannot detect any faces in the image." << endl;
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment