6
votes

I am trying to compile the facedetect.cpp in the OpenCV\Samples\C folder, in Visual Studio 2010. The project compiles and begins just fine, shows a preview of my camera, and then seems to crash at cascade.detectMultiScale() as soon as it detects a face. I concluded that OpenCV thinks I am too ugly.

Unhandled exception at 0x100342bf in HeadTrackerExample.exe: 0xC0000005: Access violation writing location 0x00000000.

Unfortunately the debug info doesn't let me probe deeper. I am linking against cv210.lib;cxcore210.lib;highgui210.lib; the debug versions won't work:

LDR: LdrpWalkImportDescriptor() failed to probe D:\OpenCV2.1\bin\cv210d.dll for its manifest, ntstatus 0xc0150002

I'm going to try to trick the classifier with a printout of Anne Hathaway but I am open to other suggestions.

https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/c/facedetect.cpp

2
Haven't got a clue, but +1 for having a sense of humour.Steve Morgan
Can you show us the code so we can see your call to cascade.detectMultiScale()? Or is the code too ugly as well? :-)SSteve
Code is now linked in the question! As you can see, it's just the included sample code, so maybe something is wrong with my system or my project configuration.Matt Montag

2 Answers

1
votes

I guess I'm better looking than you because it's working here (under OS X). Are you sure you're successfully loading the xml files? Are you using the default xml files (haarcascade_frontalface_alt.xml and haarcascade_eye_tree_eyeglasses.xml)?

It sure looks like you have a null pointer. Try setting a breakpoint at the call to cascade.detectMultiScale() and examine the values of cascade, smallImg, smallImg.data, and faces.

Edit: populating the faces vector

Here's the detectMultiScale code:

void HaarClassifierCascade::detectMultiScale( const Mat& image,
                       Vector<Rect>& objects, double scaleFactor,
                       int minNeighbors, int flags,
                       Size minSize )
{
    MemStorage storage(cvCreateMemStorage(0));
    CvMat _image = image;
    CvSeq* _objects = cvHaarDetectObjects( &_image, cascade, storage, scaleFactor,
                                           minNeighbors, flags, minSize );
    Seq<Rect>(_objects).copyTo(objects);
}

It's not touching the faces vector until the last line after all the detection is done. If you are adventurous, you could throw some printf statements in here to see if cvHaarDetectObjects is completing and if it is returning a null pointer.

0
votes

I spent the day trying to fix this. Who knows why it was crashing? I couldn't link to the debug DLLs so we'll never know. I downloaded the OpenCV-2.1.0-win32-vs2008.exe distribution. And I am using Visual Studio 2010. Therefore, the exe was crashing with

LDR: LdrpWalkImportDescriptor() failed to probe D:\OpenCV2.1\bin\cv210d.dll for its manifest, ntstatus 0xc0150002 Debugger:: An unhandled non-continuable exception was thrown during process load The program '[5172] HeadTrackerExample.exe: Native' has exited with code -1072365566 (0xc0150002).

This is the "0xc0150002 error". According to Dependency Walker, the OpenCV debug DLLs are trying to find msvcr90d.dll and msvct90d.dll, the Visual Studio 2008 debug runtime DLLs. Well, I obtained these and it still didn't work, so then this gets into esoteric Windows sidebyside and manifest stuff.

I switched to the OpenCV-2.3.1-win-superpack.exe distribution and it is now working.