Just wanted to let people know incase they run into this.
Using the ofxCvHaarFinder in 006 (on a mac) I get this error when I try and load a haar file.
OpenCV ERROR: Unspecified error (The node does not represent a user object (unknown type?))
in function cvRead, /Users/theo/Documents/CODE/__OPENFRAMEWORKS/SANDBOX/COMPILE_LIBRARIES/__openCV/openCV1.1PreCompile/cxcore/src/cxpersistence.cpp(5061)
Terminating the application...
The place this is happening is at:
cascade = (CvHaarClassifierCascade*)cvLoad( haarFile.c_str(), 0, 0, 0 );
In ofxCvHaarFinder::setup(string haarFile);
After digging around I found at the end of this page:
http://opencv.willowgarage.com/wiki/FaceDetection
A lot of people have been receiving an error while executing the following line:
cascade = (CvHaarClassifierCascade*)cvLoad(file_name,NULL, NULL, NULL);
The error looks like this: Unspecified error (The node does not represent a user object (unknown type?)) in function cvRead, C:\Program Files\OpenCV\cxcore\src\cxpersistence.cpp (5040)
The solution is to use cxcored.lib, cvd.lib and highguid.lib instead of cxcored_i7.lib, cv.lib and highgui.lib. You can use highgui.lib, but you get an error after the face detected image has been displayed and you’re unloading it.
Another simple workaround is to call any function from cv.lib before the call to cvLoad. For example: create a dummy empty image, apply cvErode to it and release the image.
But being on mac I didn’t have this option -
but then I found a bizarre solution:
http://thread.gmane.org/gmane.comp.lib.-…-ocus=17400
So I recreated the logic of it and it worked - no idea why. Here is the modified setup function with the hack to get openCV not to crash.
void ofxCvHaarFinder::setup(string haarFile) {
haarFile = ofToDataPath(haarFile);
storage = cvCreateMemStorage(0);
cvClearMemStorage( storage );
myMoments = (CvMoments*)malloc( sizeof(CvMoments) );
//total hack - loading a blank image to the haar finder to stop opencv crashing
ofxCvGrayscaleImage inImage;
ofImage tmp;
tmp.allocate(320, 240, OF_IMAGE_GRAYSCALE);
inImage.allocate(320, 240);
inImage = tmp.getPixels();
cascade = (CvHaarClassifierCascade*)cvLoad( haarFile.c_str(), 0, 0, 0 );
//hack for opencv bellow
cvHaarDetectObjects( inImage.getCvImage(), cascade, storage, scaleHaar, 2, CV_HAAR_DO_CANNY_PRUNING);
if( !cascade ){
printf("ERROR: Could not load classifier cascade\n" );
}
blobs.clear();
}
Fixed cpp and h files are also attached.
Theo