Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Need help running sample script for Cascade Classifier.

I am trying to run the C++ sample script for Cascade Classifier in Visual Studio. The script exits execution with code -1

Error loading face cascade.

The file

haarcascade_frontalface_alt.xml

is in the same folder as the script. The script has been gutted down to a few lines and, receives the same error. My test script follows . . .

What am I doing wrong?

#include "stdafx.h"

#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"

#include <stdio.h>

using namespace std;
using namespace cv;

String face_cascade_name, eyes_cascade_name;
CascadeClassifier face_cascade;
int main (int argc, const char** argv)
{
    CommandLineParser parser (argc, argv,
        "{help h||}"
        "{face_cascade|haarcascade_frontalface_alt.xml|}"
        "{eyes_cascade|haarcascade_eye_tree_eyeglasses.xml|}");

    face_cascade_name = parser.get<String>("face_cascade");
    if (!face_cascade.load(face_cascade_name)) { printf("--(!)1Error loading face cascade\n"); return -1; };

}

Need help running sample script for Cascade Classifier.

I am trying to run the C++ sample script for Cascade Classifier in Visual Studio. The script exits execution with code -1

Error loading face cascade.

The file

haarcascade_frontalface_alt.xml

is in the same folder as the script. The script has been gutted down to a few lines and, receives the same error. My test script follows . . .

What am I doing wrong?

#include "stdafx.h"

#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"

#include <stdio.h>

using namespace std;
using namespace cv;

String face_cascade_name, eyes_cascade_name;
CascadeClassifier face_cascade;
int main (int argc, const char** argv)
{
    CommandLineParser parser (argc, argv,
        "{help h||}"
        "{face_cascade|haarcascade_frontalface_alt.xml|}"
        "{eyes_cascade|haarcascade_eye_tree_eyeglasses.xml|}");

    face_cascade_name = parser.get<String>("face_cascade");
    if (!face_cascade.load(face_cascade_name)) { printf("--(!)1Error loading face cascade\n"); return -1; };

}