Ask Your Question
0

Solved Need help running sample script for Cascade Classifier.

asked 2018-04-13 09:22:14 -0600

Marko5280 gravatar image

updated 2018-04-13 11:01:20 -0600

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; };

}
edit retag flag offensive close merge delete

Comments

"is in the same folder as the script" -- it has to be in the same folder where you run the program.

(if you do this from an IDE, i might not be the project, but a debug or release folder)

berak gravatar imageberak ( 2018-04-13 09:28:46 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-04-13 11:02:00 -0600

Marko5280 gravatar image

SOLVED

Visual Studio gave a false signal that the files were next to the application. Now, the files are actually in the same folder as the script, as confirmed by the Windows 7 finder.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-04-13 09:22:14 -0600

Seen: 464 times

Last updated: Apr 13 '18