2.4.10 CascadeClassifier Unhandled exception. Access violation writing location.

asked 2015-02-08 08:38:06 -0600

aleksey_ho gravatar image

updated 2015-02-09 11:16:59 -0600

I have an exception "Unhandled exception at 0x0F633BD9 (opencv_core2410d.dll) in EyeHelper.exe: 0xC0000005: Access violation writing location 0x00000014." when i try to add simple piece of code "CascadeClassifier faceCascade;" here:

Rect getFaceCoords(Mat& frame, int algorithm)
{
    Rect faceBox;
    // add here:    
    // CascadeClassifier faceCascade;
    switch (algorithm)
    {
        //HAAR CASCADE 
    case 1:
        faceBox = Rect(20, 20, 20, 20);
        break;
    case 2:
        break;
    default:
        break;
    }
    return faceBox;
}

Without CascadeClassifier everything works fine. Exception occurs AFTER RETURN the method! i made simple bool or void function and create CascadeClassifier faceCascade there, it works, faceCascade.detectMultiScale also can find faces, but when the method is over, and it goes to return - exception. i have no idea what to do, i tried faceCascade.~CascadeClassifier(); before return, but it doesn't work as expected.

What could be the reason of exception, how to fix it (or how can i use Haar Cascade in other way)?

I'm working in VS2013, use MFC project. in project properties i have: platform toolset "Visual Studio 2013 (v120)" AdditionalLibraryDirectories $(OPENCV_BUILD)\x86\vc12\lib\; use opencv2. all AdditionalDependencies (libs) are like "opencv_core2410d.lib" (all with "d").

i'm working according to this example: http://docs.opencv.org/doc/tutorials/...

in another machine by the way everything works fine, so it's not the code error. both the machines have x64 win7. any idea?

edit retag flag offensive close merge delete

Comments

1
  • unfortunately, the code you show , seems artificially constructed, and is not helpful. can you show the real thing instead ?
  • why are you trying to call the destructor of the CascadeClassifier? (also, constructing / deleting an instance per detection sounds like a bad idea, rather have one instance around for the whole lifetime of your program)
  • "(libs) are like "opencv_core2410d.lib" (all with "d")." - that's correct for debug mode. for release, strictly use those without d.
berak gravatar imageberak ( 2015-02-08 08:51:04 -0600 )edit
1

what do you mean "real"? i'm trying to do something. i know that destructor is bad idea, without it also exception. i know that d means debug mode, i noticed it becouse i could be the reason (using release version in debug).

ALSO. in another machine by the way everything works fine, so it's not the code error. both the machines have x64 win7. any idea?

aleksey_ho gravatar imagealeksey_ho ( 2015-02-08 10:48:06 -0600 )edit