Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

CascadeClassifier

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

CascadeClassifier

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

// FaceReco.cpp : définit le point d'entrée pour l'application console. //

include <opencv2 core="" core.hpp="">

include <opencv2 contrib="" contrib.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <opencv2 objdetect="" objdetect.hpp="">

include <iostream>

include <fstream>

include <sstream>

using namespace std; using namespace cv;

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;

}

CascadeClassifier

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

// FaceReco.cpp : définit le point d'entrée pour l'application console. //

include <opencv2 core="" core.hpp="">

include <opencv2 contrib="" contrib.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <opencv2 objdetect="" objdetect.hpp="">

include <iostream>

include <fstream>

include <sstream>

using namespace std; using namespace cv;

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;

}