0

I am somewhat of a coding newbie but I have managed to create code that can scan a face image and detect the eyes using an eye haar cascade.

However I wish to also detect the face and mouth as well too using Haar Cascades but I always get an error upon loading the cascade. The .xml haar files are in the directory. Here are snippets of my code:

const char* cascade_eye = "haarcascade_eye.xml"; 
const char* cascade_mouth = "haarcascade_mcs_mouth.xml"; 
const char* cascade_face = "haarcascade_frontalface_alt.xml";

int main()
{

// ------- Initiate Haars Eye Cascade --------- //

CvHaarClassifierCascade *cascade = (CvHaarClassifierCascade*)cvLoad(cascade_eye);
if (!cascade) {
    printf("Cannot load cascade!");
    exit(-1);
}

CvHaarClassifierCascade *cascade2 = (CvHaarClassifierCascade*)cvLoad(cascade_face);
if (!cascade2) {
    printf("Cannot load cascade!");
    exit(-1);
}

CvHaarClassifierCascade *cascade3 = (CvHaarClassifierCascade*)cvLoad(cascade_mouth);
if (!cascade3) {
    printf("Cannot load cascade!");
    exit(-1);
}

If I try to only load one cascade, the cascade will be loaded and there will be no error. How do I load all three of them as I attempted above but with no error?

Miki
  • 40,887
  • 13
  • 123
  • 202
Sheraz
  • 23
  • 1
  • 4
  • 1
    Please add the error you have. Also you should really avoid obsolete C syntax and use C++ api. – Miki Jan 31 '16 at 17:48
  • "If I try to only load one cascade" does this work for ANY one of them, or only for cascade_eye? – Micka Jan 31 '16 at 18:54

0 Answers0