CascadeClassifier

asked 2014-06-26 02:07:40 -0600

Tam gravatar image

updated 2014-06-26 09:50:32 -0600

Hi all ,

I try opencv 2.4.9 on XP Visual C++ 2008. I use debug Lib on debug config and release lib on release config. I try CascadeClassifier with "haarcascade_frontalface_alt.xml" and other xml present in 2.4.9 version.

In release config CascadeClassifier.load always return false . In debug config CascadeClassifier.load crash .

Can you help me ?

Thank

Thierry

int main(int argc, char* argv[]) { int deviceId=0; VideoCapture cap(deviceId); // Check if we can use this device at all: if(!cap.isOpened()) { cerr << "Capture Device ID " << deviceId << "cannot be opened." << endl; return -1; }

//create the cascade classifier object used for the face detection
CascadeClassifier face_cascade;
//use the haarcascade_frontalface_alt.xml library
if(!face_cascade.load("D:/Projet/FaceReco/Release/haarcascade_frontalface_alt.xml"))
    cerr << "Echecc Load :" <<endl;





namedWindow("face",CV_WINDOW_AUTOSIZE); 
Mat frame;
Mat grayscaleFrame;
for(;;) 
{
    cap >> frame;
    Mat original = frame.clone();
    // Convert the current frame to grayscale:
    cvtColor(original, grayscaleFrame, CV_BGR2GRAY);
    equalizeHist(grayscaleFrame, grayscaleFrame);

    //create a vector array to store the face found
    std::vector<Rect> faces;

    //find faces and store them in the vector array
    face_cascade.detectMultiScale( grayscaleFrame, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );

    //draw a rectangle for all found faces in the vector array on the original image
    for(int i = 0; i < faces.size(); i++)
    {
        Point pt1(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
        Point pt2(faces[i].x, faces[i].y);

        rectangle(frame, pt1, pt2, cvScalar(0, 255, 0, 0), 1, 8, 0);
    }

    imshow("face", frame);
    imshow("face_gray", grayscaleFrame);
    char key = (char) waitKey(20);
    // Exit this loop on escape:
    if(key == 27)
        break;


}


return 0;

}

edit retag flag offensive close merge delete

Comments

Problem not clear! can you please add your code here?

Balaji R gravatar imageBalaji R ( 2014-06-26 06:40:12 -0600 )edit