Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Access violation when using Cascade Classifier

Hi there. I am currently trying to write some code to do Face Detection with the Cascade Classifier. I tried running the example code from the site (http://docs.opencv.org/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html). After getting an error, I tried stripping out some code to try to isolate the problem, but ultimately it seems that even creating a CascadeClassifier object causes a problem. The code is as follows:

/**
 * @file objectDetection2.cpp
 * @author A. Huaman ( based in the classic facedetect.cpp in samples/c )
 * @brief A simplified version of facedetect.cpp, show how to load a cascade classifier and how to find objects (Face + eyes) in a video stream - Using LBP here
 */
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;


int main(){

    CascadeClassifier face_cascade("haarcascade_frontalface_alt.xml");

    return 0;
}

When the main method finishes, I get an error message (see: C:\fakepath\Error.PNG). I don't see how it could possibly be a problem with the constructor for CascadeClassifier, but I'm totally bewildered as to what's going on. The file given as an argument is in the same directory as the c++ file. Anyone have any ideas? Apologies if the answer is obvious, my C++ is a bit shaky.

Cheers