I\'m trying face detection using OpenCv 2.3. My trying to load "haarcascade_frontalface_alt_tree.xml" on my project, I\'m constantly unable to load the xml file.>
To narrow down the issue, before calling cvLoad you should check to see if the file exists. Here's one way:
struct stat buf;
int statResult = stat(file,&buf);
if (statResult || buf.st_ino < 0) {
cout << "File not found: " << file << endl;
exit(-2);
}
You'll need to #include
On my system (OS X 10.6.8/OpenCV 2.3), when I attempt to load haarcascade_frontalface_alt_tree.xml or haarcascade_frontalface_alt.xml I get an exception:
OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /Users/steve/Development/opencv2/opencv/modules/core/src/persistence.cpp, line 4857
I think you are using an outdated OpenCV 1 tutorial that doesn't work with the current version of haarcascade_frontalface_alt_tree.xml. Try this OpenCV 2 tutorial instead. This code from that tutorial works for me:
CascadeClassifier face_cascade;
if (!face_cascade.load( file) ) {
cout << "Couldn't load face_cascade" << endl;
exit(-1);
}
cout << "Loaded face_cascade" << endl;