OpenCV includes face detection sample code. I tried to use facedetect.cpp from OpenCV 2.2 library in my application. However, I happened to a runtime problem
OpenCV error: Null pointer(Null filename) in unknown function, file..\..\..\..\ocv\opencv\modules\core\src\persistence.cpp,line 2571
I googled it and found lots of people ran across this problem, but without a good solution. This problem happened when code load .xml file. My solution is here:
const char *cascadeNameChar=cascadeName.c_str();
const char *nestedCascadeNameChar=nestedCascadeName.c_str();
......
if( !cvLoad( nestedCascadeNameChar ) )
if(!cascade.load(cascadeName))
Then it works for me. I run it on Visual Studio 2008.