# 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(){

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

edit retag close merge delete

Sort by » oldest newest most voted

You need to use the file's full path, if it is in a separate directory from the program's .exe in windows.

Example

This is a C string or a null terminated string, they are used to access files in opencv. In C strings \\ equates to "\" one literal backslash.

more

Thanks for replying so quickly. I tried giving the full path, and also tried putting the file in the same directory as the .exe, but it hasn't helped. I don't know if this is helpful, but the error seems to occur at the very end of the main function. If I step through just the initialisation line, I don't get the error; it only seems to occur when main finishes. So I presume it's finding the input file, but beyond that I'm not sure.

( 2013-05-15 20:42:15 -0500 )edit

Official site

GitHub

Wiki

Documentation